-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: during interchanging from non-pandas tz-aware data #54287
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 4 commits
c89377c
ddcf978
42aeee0
9448242
da6fe09
15a1fa6
dd2c3eb
c575157
0d5774e
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import pytest | ||
|
||
from pandas._libs.tslibs import iNaT | ||
from pandas.errors import SettingWithCopyError | ||
import pandas.util._test_decorators as td | ||
|
||
import pandas as pd | ||
|
@@ -295,3 +296,18 @@ def test_datetimetzdtype(tz, unit): | |
) | ||
df = pd.DataFrame({"ts_tz": tz_data}) | ||
tm.assert_frame_equal(df, from_dataframe(df.__dataframe__())) | ||
|
||
|
||
def test_interchange_from_non_pandas_tz_aware_raise_error(): | ||
# GH 54239 | ||
pa = pytest.importorskip("pyarrow") | ||
import pyarrow.compute as pc | ||
|
||
arr = pa.array([datetime(2020, 1, 1), None, datetime(2020, 1, 2)]) | ||
arr = pc.assume_timezone(arr, "Asia/Kathmandu") | ||
table = pa.table({"arr": arr}) | ||
exchange_df = table.__dataframe__() | ||
|
||
msg = "modifications to a method of a datetimelike object are not supported." | ||
with pytest.raises(SettingWithCopyError, match=msg): | ||
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. I don't think this should be raising an error though In try:
data[null_pos] = None
except TypeError:
# TypeError happens if the `data` dtype appears to be non-nullable
# in numpy notation (bool, int, uint). If this happens,
# cast the `data` to nullable float dtype.
data = data.astype(float)
data[null_pos] = None , could we add an extra 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. Thank you, I added the extra |
||
from_dataframe(exchange_df) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may need to set a minimum version here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, I added the minimum version here