-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: to_period behaves different between Timestamp and DatetimeIndex with timezones #22905
Comments
looking into this |
@miccoli , please read more about pandas.date_range() here
putting |
@brute4s99 pandas/pandas/tests/indexes/datetimes/test_astype.py Lines 266 to 285 in 14598c6
I just reproduced the situation in the test above, which fails east of greenwich. Let me explain this better:
I'm not sure if it's a bug or a feature, but I feel more natural to assume that Finally if positively |
Nice catch @miccoli! Agreed I don't work with The UTC conversion happens here in pandas/pandas/core/indexes/datetimes.py Line 746 in 2f1b842
|
Can I work this bug, please ? |
Go for it @brute4s99. Open up the pull request when you are ready for a review. |
This looks to be fixed on master now. Could use a test. |
After 935c5d1
pandas/tests/indexes/datetimes/test_astype.py
fails depending on the timezone:in fact
is OK while
fails.
This can be nailed down to the following code sample.
Code Sample
Problem description
It seems that
ts.to_period()[0] == ts[0].to_period()
depends on tzinfo, true if west of GMT, false if east of GMT. Before 935c5d1ts.to_period()[0] == ts[0].to_period()
is alwaysTrue
irrespective of tzinfo.Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: