Skip to content
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

Bugfix/groupby datetime issue #28569

Merged
merged 10 commits into from
Oct 3, 2019

Conversation

sidharthann
Copy link
Contributor

@@ -181,6 +181,7 @@ Datetimelike
- Bug in :class:`Series` and :class:`DataFrame` with integer dtype failing to raise ``TypeError`` when adding or subtracting a ``np.datetime64`` object (:issue:`28080`)
- Bug in :class:`Week` with ``weekday`` incorrectly raising ``AttributeError`` instead of ``TypeError`` when adding or subtracting an invalid type (:issue:`28530`)
- Bug in :class:`DataFrame` arithmetic operations when operating with a :class:`Series` with dtype `'timedelta64[ns]'` (:issue:`28049`)
- Bug in :func:`pandas.core.groupby.generic._recast_datetimelike_result` integer indexes for columns referenced by name (:issue:`28247`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss how a publicly-facing function (i.e. one that isn't prefixed by an underscore) was affected by this bug instead in the entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've updated.

@@ -181,7 +181,7 @@ Datetimelike
- Bug in :class:`Series` and :class:`DataFrame` with integer dtype failing to raise ``TypeError`` when adding or subtracting a ``np.datetime64`` object (:issue:`28080`)
- Bug in :class:`Week` with ``weekday`` incorrectly raising ``AttributeError`` instead of ``TypeError`` when adding or subtracting an invalid type (:issue:`28530`)
- Bug in :class:`DataFrame` arithmetic operations when operating with a :class:`Series` with dtype `'timedelta64[ns]'` (:issue:`28049`)
-
- Bug in :func:`pandas.core.groupby.generic._recast_datetimelike_result` causing ``KeyError`` in :func:`pandas.core.groupby.generic.SeriesGroupBy.apply` when a column index in the original DataFrame is datetime like(:issue:`28247`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no space between "datetime" and "like", space after "like".

The only test is for a datetime object. Does this also work for the other things we usually call "datetimelike"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, i have updated as per your suggestion, and added a few more test cases



def test_apply_datetime_issue():
# GH-28247
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a 1-line comment on what the issue is

@@ -182,7 +182,7 @@ Datetimelike
- Bug in :class:`Series` and :class:`DataFrame` with integer dtype failing to raise ``TypeError`` when adding or subtracting a ``np.datetime64`` object (:issue:`28080`)
- Bug in :class:`Week` with ``weekday`` incorrectly raising ``AttributeError`` instead of ``TypeError`` when adding or subtracting an invalid type (:issue:`28530`)
- Bug in :class:`DataFrame` arithmetic operations when operating with a :class:`Series` with dtype `'timedelta64[ns]'` (:issue:`28049`)
-
- Bug in :func:`pandas.core.groupby.generic._recast_datetimelike_result` causing ``KeyError`` in :func:`pandas.core.groupby.generic.SeriesGroupBy.apply` when a column index in the original DataFrame is datetimelike (:issue:`28247`)
Copy link
Contributor

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

@jreback jreback added this to the 1.0 milestone Oct 1, 2019
@pep8speaks
Copy link

pep8speaks commented Oct 1, 2019

Hello @sidharthann! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-10-03 05:49:18 UTC

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change in the tests, ping on green.

# is a datetime object and the column labels are different from
# standard int values in range(len(num_columns))

df = pd.DataFrame({"a": ["foo"], "b": [datetime.today()]})
Copy link
Contributor

Choose a reason for hiding this comment

The 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

@jreback jreback merged commit 4375daf into pandas-dev:master Oct 3, 2019
@jreback
Copy link
Contributor

jreback commented Oct 3, 2019

thanks @sidharthann

galuhsahid added a commit to galuhsahid/pandas that referenced this pull request Oct 4, 2019
* master: (22 commits)
  DOC: fix PR09,PR08 errors for pandas.Timestamp (pandas-dev#28739)
  WEB: Add diversity note to team.md (pandas-dev#28630)
  DOC: Minor fixes in pandas/testing.py docstring. (pandas-dev#28752)
  TST: port maybe_promote tests from pandas-dev#23982 (pandas-dev#28764)
  Bugfix/groupby datetime issue (pandas-dev#28569)
  reenable codecov (pandas-dev#28750)
  CLN: Centralised _check_percentile (pandas-dev#27584)
  DEPR: Deprecate Index.set_value (pandas-dev#28621)
  CLN: Fix typo in contributing.rst (pandas-dev#28761)
  Fixed docstring errors in pandas.period range and pandas.PeriodIndex (pandas-dev#28756)
  BUG: Fix TypeError raised in libreduction (pandas-dev#28643)
  DOC: Pandas.Series.drop docstring PR02 (pandas-dev#27976) (pandas-dev#28742)
  DOC: Fixed doctring errors PR08, PR09 in pandas.io (pandas-dev#28748)
  TST: Fix broken test cases where Timedelta/Timestamp raise (pandas-dev#28729)
  REF: Consolidate alignment calls in DataFrame ops (pandas-dev#28638)
  BUG: Fix dep generation (pandas-dev#28734)
  Added doctstring to fixture (pandas-dev#28727)
  DOC: Fixed PR06 docstrings errors in pandas.timedelta_range (pandas-dev#28719)
  replaced safe_import with a corresponding test decorator (pandas-dev#28731)
  BUG: Fix RangeIndex.get_indexer for decreasing RangeIndex (pandas-dev#28680)
  ...
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
@sidharthann sidharthann deleted the bugfix/groupby_datetime_issue branch January 18, 2020 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug][Regression] df.groupby.apply fails under specific conditions
5 participants