-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Can't restore index from parquet with offset-specified timezone #35997 #36004
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 all commits
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 |
---|---|---|
|
@@ -125,6 +125,21 @@ def df_full(): | |
) | ||
|
||
|
||
@pytest.fixture( | ||
params=[ | ||
datetime.datetime.now(datetime.timezone.utc), | ||
datetime.datetime.now(datetime.timezone.min), | ||
datetime.datetime.now(datetime.timezone.max), | ||
datetime.datetime.strptime("2019-01-04T16:41:24+0200", "%Y-%m-%dT%H:%M:%S%z"), | ||
datetime.datetime.strptime("2019-01-04T16:41:24+0215", "%Y-%m-%dT%H:%M:%S%z"), | ||
datetime.datetime.strptime("2019-01-04T16:41:24-0200", "%Y-%m-%dT%H:%M:%S%z"), | ||
datetime.datetime.strptime("2019-01-04T16:41:24-0215", "%Y-%m-%dT%H:%M:%S%z"), | ||
] | ||
) | ||
def timezone_aware_date_list(request): | ||
alippai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return request.param | ||
|
||
|
||
def check_round_trip( | ||
df, | ||
engine=None, | ||
|
@@ -134,6 +149,7 @@ def check_round_trip( | |
expected=None, | ||
check_names=True, | ||
check_like=False, | ||
check_dtype=True, | ||
repeat=2, | ||
): | ||
"""Verify parquet serializer and deserializer produce the same results. | ||
|
@@ -175,7 +191,11 @@ def compare(repeat): | |
actual = read_parquet(path, **read_kwargs) | ||
|
||
tm.assert_frame_equal( | ||
expected, actual, check_names=check_names, check_like=check_like | ||
expected, | ||
actual, | ||
check_names=check_names, | ||
check_like=check_like, | ||
check_dtype=check_dtype, | ||
) | ||
|
||
if path is None: | ||
|
@@ -739,6 +759,21 @@ def test_timestamp_nanoseconds(self, pa): | |
df = pd.DataFrame({"a": pd.date_range("2017-01-01", freq="1n", periods=10)}) | ||
check_round_trip(df, pa, write_kwargs={"version": "2.0"}) | ||
|
||
def test_timezone_aware_index(self, pa, timezone_aware_date_list): | ||
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 change this so that on future versions of pyarrow it will set check_dtype=True (IOW when the bug is fixed). otherwise I am worried this will perpetuate forever. alternatively, could remove the check_dtype and just xfail this (and when new pyarrow fixes this test will then start to xpass which will make it fail as we have strict=True). so again could make this a conditional on an older / newer version of pyarrow. 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. @jreback based on the comment above by @jorisvandenbossche , I don't expect this to be "fixed" in Arrow. 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. Yes, there are no active plans in pyarrow to change this. Although it makes probably sense to use 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. @jreback I added a long description. I know this won't help a follow up improvement in the future, but at this point it's unlikely to change. There are two scenarios:
I don't see any of them on the short or mid-term roadmap. |
||
idx = 5 * [timezone_aware_date_list] | ||
df = pd.DataFrame(index=idx, data={"index_as_col": idx}) | ||
|
||
# see gh-36004 | ||
# compare time(zone) values only, skip their class: | ||
# pyarrow always creates fixed offset timezones using pytz.FixedOffset() | ||
# even if it was datetime.timezone() originally | ||
# | ||
# technically they are the same: | ||
# they both implement datetime.tzinfo | ||
# they both wrap datetime.timedelta() | ||
# this use-case sets the resolution to 1 minute | ||
check_round_trip(df, pa, check_dtype=False) | ||
|
||
@td.skip_if_no("pyarrow", min_version="0.17") | ||
def test_filter_row_groups(self, pa): | ||
# https://github.com/pandas-dev/pandas/issues/26551 | ||
|
@@ -877,3 +912,12 @@ def test_empty_dataframe(self, fp): | |
expected = df.copy() | ||
expected.index.name = "index" | ||
check_round_trip(df, fp, expected=expected) | ||
|
||
def test_timezone_aware_index(self, fp, timezone_aware_date_list): | ||
idx = 5 * [timezone_aware_date_list] | ||
|
||
df = pd.DataFrame(index=idx, data={"index_as_col": idx}) | ||
|
||
expected = df.copy() | ||
expected.index.name = "index" | ||
check_round_trip(df, fp, expected=expected) |
Uh oh!
There was an error while loading. Please reload this page.