We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5a74464 commit 33ef3d7Copy full SHA for 33ef3d7
bisect/46297.py
@@ -0,0 +1,15 @@
1
+# BUG: Error writing DataFrame with categorical type column and interval data to a CSV file #46297
2
+
3
+import pandas as pd
4
5
+print(pd.__version__)
6
7
+df = pd.DataFrame(index=[0], columns=["a"])
8
+df.at[0, "a"] = pd.Interval(pd.Timestamp("2020-01-01"), pd.Timestamp("2020-01-02"))
9
+df["a"] = df["a"].astype("category") # astype("object") does not raise an error
10
11
+result = df.to_csv()
12
+print(result)
13
14
+expected = ',a\n0,"(2020-01-01, 2020-01-02]"\n'
15
+assert result == expected
0 commit comments