Skip to content

Commit 9a68635

Browse files
jbrockmendelTomAugspurger
authored andcommitted
BUG: SystemError in df.sum (#30905)
1 parent 2cabca8 commit 9a68635

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pandas/_libs/tslibs/c_timestamp.pyx

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ def integer_op_not_supported(obj):
5757
# the caller; mypy finds this more palatable.
5858
cls = type(obj).__name__
5959

60+
# GH#30886 using an fstring raises SystemError
6061
int_addsub_msg = (
61-
f"Addition/subtraction of integers and integer-arrays with {cls} is "
62+
"Addition/subtraction of integers and integer-arrays with {cls} is "
6263
"no longer supported. Instead of adding/subtracting `n`, "
6364
"use `n * obj.freq`"
64-
)
65+
).format(cls=cls)
6566
return TypeError(int_addsub_msg)
6667

6768

pandas/tests/frame/test_analytics.py

+10
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,16 @@ def test_sum_bool(self, float_frame):
823823
bools.sum(1)
824824
bools.sum(0)
825825

826+
def test_sum_mixed_datetime(self):
827+
# GH#30886
828+
df = pd.DataFrame(
829+
{"A": pd.date_range("2000", periods=4), "B": [1, 2, 3, 4]}
830+
).reindex([2, 3, 4])
831+
result = df.sum()
832+
833+
expected = pd.Series({"B": 7.0})
834+
tm.assert_series_equal(result, expected)
835+
826836
def test_mean_corner(self, float_frame, float_string_frame):
827837
# unit test when have object data
828838
the_mean = float_string_frame.mean(axis=0)

0 commit comments

Comments
 (0)