-
-
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
REGR: Regression in to_csv for ea dtype categorical #47347
Changes from 5 commits
809094e
700331f
b78a2f3
90deb17
505ff57
e1e946d
4fd9966
e946026
95696aa
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 |
---|---|---|
|
@@ -1285,3 +1285,24 @@ def test_to_csv_na_quoting(self): | |
) | ||
expected = '""\n""\n' | ||
assert result == expected | ||
|
||
def test_to_csv_categorical_and_ea(self): | ||
# GH#46812 | ||
df = DataFrame({"a": "x", "b": [1, pd.NA]}) | ||
df["b"] = df["b"].astype("Int16") | ||
df["b"] = df["b"].astype("category") | ||
result = df.to_csv() | ||
expected_rows = [",a,b", "0,x,1", "1,x,"] | ||
expected = tm.convert_rows_list_to_csv_str(expected_rows) | ||
assert result == expected | ||
|
||
def test_to_csv_categorical_and_interval(self): | ||
# GH#46297 | ||
df = DataFrame( | ||
{"a": [pd.Interval(Timestamp("2020-01-01"), Timestamp("2020-01-02"))]} | ||
) | ||
df["a"] = df["a"].astype("category") # astype("object") does not raise an error | ||
result = df.to_csv() | ||
expected_rows = [",a", '0,"[2020-01-01, 2020-01-02]"'] | ||
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. has the default closed argument changed on main? on 1.3.5 and 1.4.2, the expected would be print(pd.__version__)
i = pd.Interval(pd.Timestamp("2020-01-01"), pd.Timestamp("2020-01-02"))
print(repr(i))
print(i)
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. Looks like it. Inclusive was added which defaults to both, when close is not given. I could not find this in the release notes, so we should either add it or change back to right. Probably would have to deprecate first. For this pr, I will add closed as a keyword and catch the deprecation warning for main, then we can adjust the test as a follow up 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.
sgtm 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. opened #47365 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. Changed here |
||
expected = tm.convert_rows_list_to_csv_str(expected_rows) | ||
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.
probably can remove this comment that was in the issue OP
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.
Thx, should have paid more attention…
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.
Done