-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Group-by numeric type-coercion with datetime #15680
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 2 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 |
---|---|---|
|
@@ -4314,6 +4314,16 @@ def test_cummin_cummax(self): | |
expected = pd.Series([1, 2, 1], name='b') | ||
tm.assert_series_equal(result, expected) | ||
|
||
def test_numeric_coercion(self): | ||
# GH 14423 | ||
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. there are a couple of issues marked duplicate can u add there tests here as well (inside this test is ok) 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. add a 1-liner explaining this (maybe also make the test name a bit more descriptive) |
||
df = pd.DataFrame({'Number': [1, 2], | ||
'Date': ["2017-03-02"] * 2, | ||
'Str': ["foo", "inf"]}) | ||
expected = df.groupby(['Number']).apply(lambda x: x.iloc[0]) | ||
df.Date = pd.to_datetime(df.Date) | ||
result = df.groupby(['Number']).apply(lambda x: x.iloc[0]) | ||
tm.assert_series_equal(result['Str'], expected['Str']) | ||
|
||
|
||
def _check_groupby(df, result, keys, field, f=lambda x: x.sum()): | ||
tups = lmap(tuple, df[keys].values) | ||
|
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.
don't import pd
import to_numeric from pandas.util.misc (inside the function)
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.
or u can import pd inside the function is ok too