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

REGR: DatetimeTZDtype.__from_arrow__ interprets UTC values as local wall time #56775

Closed
jorisvandenbossche opened this issue Jan 8, 2024 · 1 comment · Fixed by #56922
Closed
Labels
Arrow pyarrow functionality Blocker Blocking issue or pull request for an upcoming release Regression Functionality that used to work in a prior pandas version Timezones Timezone data dtype
Milestone

Comments

@jorisvandenbossche
Copy link
Member

Using the latest pandas:

In [6]: ser = pd.Series(pd.to_datetime(["2012-01-01", "2012-01-02"]).tz_localize("Europe/Brussels"))

In [7]: ser
Out[7]: 
0   2012-01-01 00:00:00+01:00
1   2012-01-02 00:00:00+01:00
dtype: datetime64[ns, Europe/Brussels]

In [8]: pa.array(ser)
Out[8]: 
<pyarrow.lib.TimestampArray object at 0x7f695b4625c0>
[
  2011-12-31 23:00:00.000000000,   # <-- those values show the UTC timestamps, so this is correct
  2012-01-01 23:00:00.000000000
]

In [9]: ser.dtype.__from_arrow__(pa.array(ser))
Out[9]: 
<DatetimeArray>
['2011-12-31 23:00:00+01:00', '2012-01-01 23:00:00+01:00']   # <-- still the UTC wall time, but with tz offset -> wrong
Length: 2, dtype: datetime64[ns, Europe/Brussels]

I assume this is caused by #56043 cc @jbrockmendel

@jorisvandenbossche jorisvandenbossche added Regression Functionality that used to work in a prior pandas version Timezones Timezone data dtype Arrow pyarrow functionality labels Jan 8, 2024
@jorisvandenbossche jorisvandenbossche added this to the 2.2 milestone Jan 8, 2024
@lithomas1 lithomas1 added the Blocker Blocking issue or pull request for an upcoming release label Jan 10, 2024
@jbrockmendel
Copy link
Member

In DatetimeTZDtype.__from_arrow__, the following edit seems to fix this:

+        return DatetimeArray._simple_new(np_arr, dtype=self)
-        return DatetimeArray._from_sequence(np_arr, dtype=self, copy=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Blocker Blocking issue or pull request for an upcoming release Regression Functionality that used to work in a prior pandas version Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants