You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using pd.DataFrame.describe, if your percentiles are different only at the 4th decimal place, a ValueError is thrown because the the percentiles that vary at the 4th decimal place become the same value.
In [1]: s = Series(np.random.randn(10))
In [2]: s.describe()
Out[2]:
count 10.000000
mean 0.291571
std 1.057143
min -1.453547
25% -0.614614
50% 0.637435
75% 0.968905
max 1.823964
dtype: float64
In [3]: s.describe(percentiles=[0.0001, 0.0005, 0.001, 0.999, 0.9995, 0.9999])
Out[3]:
count 10.000000
mean 0.291571
std 1.057143
min -1.453547
0.0% -1.453107
0.1% -1.451348
0.1% -1.449149
50% 0.637435
99.9% 1.817201
100.0% 1.820583
100.0% 1.823288
max 1.823964
dtype: float64
You would have to determine the first significant decimal place that
provides unique string identifiers for each percentile. I'm not trained as
a programmer, but I would be surprised if there isn't a standard way to do
this.
It seems like by design someone coded in to only show 1 decimal place.
def pretty_name(x):
x *= 100
if x == int(x):
return '%.0f%%' % x
else:
return '%.1f%%' % x
What would be an appropriate fix? Change decimal place if input has more
decimals in place?
First timer here. Hope I'm not stepping bounds...just wanted to see how I
can start contributing to the project and learn about python.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #13104 (comment)
In fact, it might be done by taking np.ediff1d(np.log10([100_percentiles]))
or replacing 100_percentiles with the decimals that remain after taking
100*percentiles. Round that result to the left on the number line, and take
the most negative of the numbers. That would be the denial place precision
necessary to get a unique index. Though this could be way too complicated a
formulation.
You would have to determine the first significant decimal place that
provides unique string identifiers for each percentile. I'm not trained as
a programmer, but I would be surprised if there isn't a standard way to do
this.
It seems like by design someone coded in to only show 1 decimal place.
def pretty_name(x):
x *= 100
if x == int(x):
return '%.0f%%' % x
else:
return '%.1f%%' % x
What would be an appropriate fix? Change decimal place if input has more
decimals in place?
First timer here. Hope I'm not stepping bounds...just wanted to see how I
can start contributing to the project and learn about python.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #13104 (comment)
Test it. Does it work for cases in which you have a different number of
decimal places in the percentiles input? How anesthetically clean are the
results?
I'm actually not in favor of the warning because (1) it is only going to be
raised once; (2) we don't know how the user will use the percentiles (e.g.do
they iterate through them in the describe output?); and (3) it permits
sloppy coding that could cause someone problems later.
If you want the ability for duplicate percentiles, then how about a kwarg
like warn_on_dupe so that the default is an error and someone has to
explicitly request duplicates?
I was only proposing the warning for completeness. That being said, the
percentiles should be sorted so that the index is monotonic.
Slightly off-topic: if I keep finding other bugs and can fix them, should I open a new issue to discuss the code changes I propose? Or is it enough to discuss it in a pull request comments?
As an illustration, another bug with describe, this time unrelated to percentiles:
df=pd.DataFrame({'A': list("BCDE"), 0: [1,2,3,4]})
df.describe()
# long traceback listing several internal functionsValueError: Bufferdtypemismatch, expected'Python object'butgot'long'
I've found the source of the error and have a seemingly reasonable solution (it still needs testing, though).
Slightly off-topic: if I keep finding other bugs and can fix them, should
I open a new issue to discuss the code changes I propose? Or is it enough
to discuss it in a pull request comments?
As an illustration, another bug with describe, this time unrelated to
percentiles:
df = pd.DataFrame({'A': list("BCDE"), 0: [1,2,3,4]})
df.describe()# long traceback listing several internal functionsValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
I've found the source of the error and have a seemingly reasonable
solution (it still needs testing, though).
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #13104 (comment)
Yes it's distinct and I don't want to discuss it here. But I was going to fix it in the same commit because the code changes will probably be contained within the function describe.
My question was essentially: does any code change require opening a new issue? Wiki says not necessarily but mentions only insignificant changes.
Activity
jreback commentedon May 6, 2016
@bla1089 can you add the example which raises.
blalterman commentedon May 10, 2016
You would have to determine the first significant decimal place that
provides unique string identifiers for each percentile. I'm not trained as
a programmer, but I would be surprised if there isn't a standard way to do
this.
On Tue, May 10, 2016, 09:23 teaspreader notifications@github.com wrote:
blalterman commentedon May 10, 2016
In fact, it might be done by taking np.ediff1d(np.log10([100_percentiles]))
or replacing 100_percentiles with the decimals that remain after taking
100*percentiles. Round that result to the left on the number line, and take
the most negative of the numbers. That would be the denial place precision
necessary to get a unique index. Though this could be way too complicated a
formulation.
On Tue, May 10, 2016, 09:45 Ben Alterman alterman.ben@gmail.com wrote:
blalterman commentedon May 10, 2016
Test it. Does it work for cases in which you have a different number of
decimal places in the percentiles input? How anesthetically clean are the
results?
On Tue, May 10, 2016, 09:58 teaspreader notifications@github.com wrote:
srib commentedon May 10, 2016
I cannot seem to reproduce this issue on my machine.
22 remaining items
blalterman commentedon May 24, 2016
I'm actually not in favor of the warning because (1) it is only going to be
raised once; (2) we don't know how the user will use the percentiles (e.g.do
they iterate through them in the describe output?); and (3) it permits
sloppy coding that could cause someone problems later.
If you want the ability for duplicate percentiles, then how about a kwarg
like
warn_on_dupeso that the default is an error and someone has toexplicitly request duplicates?
I was only proposing the warning for completeness. That being said, the
percentiles should be sorted so that the index is monotonic.
On Tue, May 24, 2016, 11:11 Jeff Reback notifications@github.com wrote:
pijucha commentedon May 25, 2016
Yes, this sounds reasonable. Exceptions then.
Slightly off-topic: if I keep finding other bugs and can fix them, should I open a new issue to discuss the code changes I propose? Or is it enough to discuss it in a pull request comments?
As an illustration, another bug with
describe, this time unrelated to percentiles:I've found the source of the error and have a seemingly reasonable solution (it still needs testing, though).
blalterman commentedon May 25, 2016
This seems reasonably distinct and should probably be handled on its own.
On Wed, May 25, 2016, 10:06 pijucha notifications@github.com wrote:
pijucha commentedon May 25, 2016
Yes it's distinct and I don't want to discuss it here. But I was going to fix it in the same commit because the code changes will probably be contained within the function
describe.My question was essentially: does any code change require opening a new issue? Wiki says not necessarily but mentions only insignificant changes.
jreback commentedon May 25, 2016
generally we like to have issues to go with PR's.
pijucha commentedon May 25, 2016
Ok, thanks. I'll open a new one then.
BUG: Fix describe(): percentiles (#13104), col index (#13288)