-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Fix bug in window function count should count anything non-null #15196
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
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,38 @@ def f(): | |
'A', 'ra', 'std'), ('B', 'rb', 'mean'), ('B', 'rb', 'std')]) | ||
tm.assert_frame_equal(result, expected, check_like=True) | ||
|
||
def test_count_nonnumeric_types(self): | ||
# GH12541 | ||
cols = ['int', 'float', 'string', 'datetime', 'timedelta', | ||
'fl_inf', 'fl_nan', 'str_nan', 'dt_nat'] | ||
|
||
df = DataFrame( | ||
{'int': [1, 2, 3], | ||
'float': [4., 5., 6.], | ||
'string': list('abc'), | ||
'datetime': pd.date_range('20170101', periods=3), | ||
'timedelta': pd.timedelta_range('1 s', periods=3, freq='s'), | ||
'fl_inf': [1., 2., np.Inf], | ||
'fl_nan': [1., 2., np.NaN], | ||
'str_nan': ['aa', 'bb', np.NaN], | ||
'dt_nat': [pd.Timestamp('20170101'), pd.Timestamp('20170203'), | ||
pd.Timestamp(None)]}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we also need to test Periods? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure could add periods in here as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like this?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep |
||
columns=cols) | ||
|
||
expected = DataFrame( | ||
{'int': [1., 2., 2.], | ||
'float': [1., 2., 2.], | ||
'string': [1., 2., 2.], | ||
'datetime': [1., 2., 2.], | ||
'timedelta': [1., 2., 2.], | ||
'fl_inf': [1., 2., 2.], | ||
'fl_nan': [1., 2., 1.], | ||
'str_nan': [1., 2., 1.], | ||
'dt_nat': [1., 2., 1.]}, | ||
columns=cols) | ||
|
||
self.assert_frame_equal(df.rolling(window=2).count(), expected) | ||
|
||
def test_window_with_args(self): | ||
tm._skip_if_no_scipy() | ||
|
||
|
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.
You removed something here by accident I think
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.
Ops, sorry about that!