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
The docstring shows a numeric_only option for DataFrame.std() but it does not seem to actually be implemented. I'm happy to take a crack at fixing it but I'm not sure whether it's the doc or the implementation that needs fixing.
To see this consider a mixed-type DataFrame where I'm setting one entry to be a str of '100' while all other entries are float. For std() It does not matter whether numeric_only is True or False, but for max() it clearly makes a difference.
In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: df = pd.DataFrame(np.random.randn(5, 2), columns=['foo', 'bar'])
In [4]: df.ix[0, 'foo'] = '100'
In [5]: df
Out[5]:
foo bar
0 100 -1.958036
1 0.221049 0.309971
2 1.200093 -0.103244
3 -2.475388 -2.279483
4 0.1623936 -1.185682
In [6]: df.std(numeric_only=True)
Out[6]:
foo 44.841828
bar 1.129182
dtype: float64
In [7]: df.std(numeric_only=False)
Out[7]:
foo 44.841828
bar 1.129182
dtype: float64
In [8]: df.max(numeric_only=False)
Out[8]:
foo 100.000000
bar 0.309971
dtype: float64
In [9]: df.max(numeric_only=True)
Out[9]:
bar 0.309971
dtype: float64
The text was updated successfully, but these errors were encountered:
numeric_only matters if axis=1 otherwise the dtype controls what happens
your first column is an object dtype
max and min will work on an object dtype (though not sure what std should do here - you would have to trace it and see)
I see. But even for axis=1 it seems to be inconsistent. You can see below that numeric_only has an effect on max(), but for std() it makes no difference
The docstring shows a
numeric_only
option forDataFrame.std()
but it does not seem to actually be implemented. I'm happy to take a crack at fixing it but I'm not sure whether it's the doc or the implementation that needs fixing.To see this consider a mixed-type
DataFrame
where I'm setting one entry to be astr
of'100'
while all other entries arefloat
. Forstd()
It does not matter whethernumeric_only
isTrue
orFalse
, but formax()
it clearly makes a difference.The text was updated successfully, but these errors were encountered: