We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8fea244 commit 0971014Copy full SHA for 0971014
bisect/42659.py
@@ -0,0 +1,22 @@
1
+# BUG:dataframe.groupby('some_column').timedelta.sum() results wrong when timedelta contains NaT (pandas=1.3.0) #42659
2
+
3
+import numpy as np
4
+import pandas as pd
5
6
+print(pd.__version__)
7
8
+df = pd.DataFrame(
9
+ {
10
+ "id": ["1624477460271-3908654213", "1624477460271-3908654213"],
11
+ "dt": [np.nan, pd.to_timedelta("0:0:2")],
12
+ }
13
+)
14
+result = df.groupby("id").dt.sum()
15
+print(result)
16
17
+expected = pd.Series(
18
+ [pd.to_timedelta("0:0:2")],
19
+ index=pd.Index(["1624477460271-3908654213"], name="id"),
20
+ name="dt",
21
22
+pd.testing.assert_series_equal(result, expected)
0 commit comments