Skip to content

Resolving Index Resetting for tz_localize #43226

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

Merged
merged 25 commits into from
Sep 5, 2021

Conversation

kurchi1205
Copy link
Contributor

@kurchi1205 kurchi1205 commented Aug 26, 2021

  • closes BUG: dt.tz_convert() on categorical[datetime] resets index #43080
  • tests added / passed
    I have added a test function test_series_tz_localize_matching_index in test_tz_localize.py
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry
    Index of the original series is preserved while converting categorical data to datetime

@pep8speaks
Copy link

pep8speaks commented Aug 26, 2021

Hello @kurchi1205! 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 2021-09-03 07:38:24 UTC

@kurchi1205
Copy link
Contributor Author

@mroeschke Can you please review this pull request .

@mroeschke
Copy link
Member

As the pep8speaks comment notes, you have some code style issues in your test.

Please run pre-commit on your code before committing them: https://pandas.pydata.org/pandas-docs/stable/development/contributing_codebase.html#pre-commit

@kurchi1205
Copy link
Contributor Author

I have solved the code issues using pre-commit .

@@ -25,8 +25,8 @@ Fixed regressions

Bug fixes
~~~~~~~~~
- Bug in :meth:`.DataFrameGroupBy.agg` and :meth:`.DataFrameGroupBy.transform` with ``engine="numba"`` where ``index`` data was not being correctly passed into ``func`` (:issue:`43133`)
-
- Bug in :meth:`.DataFrameGroupBy.agg` and :meth:`.DataFrameGroupBy.transform` with engine="numba" where index data was not being correctly passed into func (:issue:`43133`)
Copy link
Member

Choose a reason for hiding this comment

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

Please revert the changes to this entry.

- Bug in :meth:`.DataFrameGroupBy.agg` and :meth:`.DataFrameGroupBy.transform` with ``engine="numba"`` where ``index`` data was not being correctly passed into ``func`` (:issue:`43133`)
-
- Bug in :meth:`.DataFrameGroupBy.agg` and :meth:`.DataFrameGroupBy.transform` with engine="numba" where index data was not being correctly passed into func (:issue:`43133`)
- Fixed bug in :func:`__new__` of :class:`CombinedDatetimelikeProperties` maintains index of Categorical Datetime series (:issue:`43080`)
Copy link
Member

Choose a reason for hiding this comment

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

  1. This note should go in v.1.4.0.rst
  2. The message should relate to a user facing API i.e. dt.tz_convert on a CategorialIndex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I will make the necessary changes ,
Just wanted to be clear , why it shouldn't be in v.1.3.3.rst ?

Copy link
Member

Choose a reason for hiding this comment

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

1.3.3 is typically for regressions or bugs for very recently added features

@mroeschke mroeschke added Categorical Categorical Data Type Timezones Timezone data dtype labels Aug 27, 2021
date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"),
index=[2, 6, 7, 8, 11],
)
cat_series = dt_series.astype(CategoricalDtype())
Copy link
Member

Choose a reason for hiding this comment

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

Can you construct without astype?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah , I have done that .

@@ -276,7 +276,7 @@ Timedelta

Timezones
^^^^^^^^^
-
- Bug in :meth:`dt.tz_convert` resetting index in a :class:`Series` with :class:`CategoricalIndex` (:issue:`43080`)
Copy link
Contributor

Choose a reason for hiding this comment

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

this won't render, try Series.dt.tz_convert

@jreback jreback added this to the 1.4 milestone Aug 31, 2021
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.

this looks good. comment & pls merge master and ping on green.

@kurchi1205
Copy link
Contributor Author

I have made the change in the documentation .

@kurchi1205
Copy link
Contributor Author

I assume some maintainer has to merge the pull request.

@kurchi1205
Copy link
Contributor Author

How to solve this timeout error ?

kurchi1205 and others added 4 commits September 1, 2021 14:55
Committing again with no changes to solve timeout error
@jreback
Copy link
Contributor

jreback commented Sep 5, 2021

lgtm @phofl merge when good

@kurchi1205
Copy link
Contributor Author

Can someone help me understand this failing test ? How are my changes affecting this test case ?

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

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

Lgtm failure unrelated

@phofl phofl merged commit 35d52ff into pandas-dev:master Sep 5, 2021
@phofl
Copy link
Member

phofl commented Sep 5, 2021

Thx @kurchi1205

@kurchi1205
Copy link
Contributor Author

ok thnx for the clarification

feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
* Resolving Index Resetting for tz_localize

* Update test_tz_localize.py

Adding a test case

* Solving PEP-8 Issues

* Changing Test Case and updating whatsnew

* Changing Test Case and updating whatsnew

* updating whatsnew

* updating whatsnew

* updating whatsnew

* Making the necessary changes

* Update test_tz_localize.py

* Update test_tz_localize.py

* Changes made

* Update test_tz_localize.py

* Commiting Again

* Change in whatsnew

* Update v1.4.0.rst

Committing again with no changes to solve timeout error

* Pre-commiting

* Pre-commiting

* New Test Case

* Test Case Modified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: dt.tz_convert() on categorical[datetime] resets index
5 participants