-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Bugfix/groupby datetime issue #28569
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 7 commits
f1befd1
2c2dacb
3880c9d
572e53d
2b6cdcd
542af30
1fa8a6e
03d2d0b
0c6060a
7132a7b
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 |
---|---|---|
|
@@ -657,3 +657,31 @@ def test_apply_with_mixed_types(): | |
|
||
result = g.apply(lambda x: x / x.sum()) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_apply_datetime_issue(): | ||
# GH-28247 | ||
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. can you add a 1-line comment on what the issue is |
||
|
||
df = pd.DataFrame({"a": ["foo"], "b": [datetime.today()]}) | ||
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. can you parameterize these tests, only thing changing is the b column which you can pass in the paramters |
||
result = df.groupby("a").apply(lambda x: pd.Series(["spam"], index=[42])) | ||
|
||
expected = pd.DataFrame( | ||
["spam"], Index(["foo"], dtype="object", name="a"), columns=[42] | ||
) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
df = pd.DataFrame({"a": ["foo"], "b": [datetime.today().date()]}) | ||
result = df.groupby("a").apply(lambda x: pd.Series(["spam"], index=[42])) | ||
|
||
expected = pd.DataFrame( | ||
["spam"], Index(["foo"], dtype="object", name="a"), columns=[42] | ||
) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
df = pd.DataFrame({"a": ["foo"], "b": [datetime.today().time()]}) | ||
result = df.groupby("a").apply(lambda x: pd.Series(["spam"], index=[42])) | ||
|
||
expected = pd.DataFrame( | ||
["spam"], Index(["foo"], dtype="object", name="a"), columns=[42] | ||
) | ||
tm.assert_frame_equal(result, expected) |
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.
can you not reference internal functions; and make this what a user cares about