We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aab896d commit 8e99991Copy full SHA for 8e99991
bisect/29824.py
@@ -0,0 +1,21 @@
1
+# using to_dict with the 'records' orient produces different results from the default one #29824
2
+
3
+import datetime
4
5
+import pandas as pd
6
7
+print(pd.__version__)
8
9
+df = pd.DataFrame({"d": pd.date_range("2018-01-01", freq="12h", periods=2)})
10
+for col in df.select_dtypes(["datetime"]):
11
+ df[col] = pd.Series(df[col].dt.to_pydatetime(), dtype="object")
12
13
+result = df.to_dict("records")
14
+print(result)
15
16
+assert type(result[0]["d"]) is datetime.datetime, type(result[0]["d"])
17
18
+result = df.to_dict("split")
19
20
21
+assert type(result["data"][0][0]) is datetime.datetime, type(result["data"][0][0])
0 commit comments