-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: DataFrame repr with ArrowDtype with extension #54130
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
ca5e77f
1a4e32d
b839b0e
0c20f1d
5fffae0
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 |
---|---|---|
|
@@ -61,6 +61,7 @@ | |
pa = pytest.importorskip("pyarrow", minversion="7.0.0") | ||
|
||
from pandas.core.arrays.arrow.array import ArrowExtensionArray | ||
from pandas.core.arrays.arrow.extension_types import ArrowPeriodType | ||
|
||
|
||
@pytest.fixture(params=tm.ALL_PYARROW_DTYPES, ids=str) | ||
|
@@ -3143,3 +3144,17 @@ def test_to_numpy_temporal(pa_type): | |
expected = np.array(expected, dtype=object) | ||
assert result[0].unit == expected[0].unit | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
|
||
def test_arrowextensiondtype_dataframe_repr(): | ||
# GH 54062 | ||
df = pd.DataFrame( | ||
pd.period_range("2012", periods=3), | ||
columns=["col"], | ||
dtype=ArrowDtype(ArrowPeriodType("D")), | ||
) | ||
result = repr(df) | ||
# TODO: repr value may not be expected; address how | ||
# pyarrow.ExtensionType values are displayed | ||
expected = " col\n0 15340\n1 15341\n2 15342" | ||
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. where does "15340" come from? i'd expect something like "2012-01-01" 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 think this is because 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. im unclear on if this should be considered "wrong"? or just orthogonal to what this PR is doing? seems like this would be an unhelpful repr to give a user 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 think it's a orthogonal incorrect behavior. This PR addresses a bug where 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. make sense 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. maybe a comment that this test shouldn't be interpreted as saying this repr is "correct"? 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. Sure. Added a comment |
||
assert result == expected |
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.
is this going to match the storage_type?
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.
Yeah, the python type of the
storage_type