-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
added mising numeric_only option for DataFrame.std/var/sem #9209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -11458,6 +11458,21 @@ def test_var_std(self): | |||
self.assertFalse((result < 0).any()) | |||
nanops._USE_BOTTLENECK = True | |||
|
|||
def test_numeric_only_flag(self): | |||
methods = ['sem', 'var', 'std'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add the issue number in a comment here
pls add a release note in the Bug Fix section of 0.16 |
@jreback updated, please take a look, thanks |
|
||
df2 = DataFrame(np.random.randn(5, 3), columns=['foo', 'bar', 'baz']) | ||
# set one entry in a non-existing column to a str | ||
df2.ix[0, 'a'] = '150' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean set the entry to 'a', e.g. make it an object series that has a completely invalid string (and not a string-like number)
c5adc3e
to
c74b932
Compare
@jreback PR updated, please take a look |
I think that if u have a string 100 in a column and the rest are actual float/int values (thus dtype is object) thrn this should always raise a ValueError and not do the coercion it hides errors to evaluate the string as a number |
that's a good point. I'll dig into this. |
@mortada pls rebase and update according to the last. thanks |
pls rebase |
@jreback just rebased, sorry I've been pretty swamped and haven't got around to this. But I should have more time going forward. |
2e51776
to
414b31a
Compare
@jreback rebased and addressed the issue you mentioned about type coercion. Please take a look. With this PR This is now consistent with the behavior of other methods such as |
added mising numeric_only option for DataFrame.std/var/sem
thanks! |
closes #9201, the
numeric_only
option is missing forDataFrame.std()
(and alsoDataFrame.var()
andDataFrame.sem()
), this is a fix for it