From 230f19103d499bc90e62d17c395a1b9ca232f5f7 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Thu, 13 Sep 2018 09:45:44 -0700 Subject: [PATCH 1/2] TST: test for correct broadcasting in column-wise op --- pandas/tests/frame/test_arithmetic.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index a6f4e0e38ec5d..dc41c563d9424 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -100,6 +100,16 @@ def test_df_flex_cmp_constant_return_types_empty(self, opname): # Arithmetic class TestFrameFlexArithmetic(object): + def test_df_add_td64_columnwise(self): + # GH#22534 Check that column-wise addition broadcasts correctly + dti = pd.date_range('2016-01-01', periods=10) + tdi = pd.timedelta_range('1', periods=10) + tser = pd.Series(tdi) + result = pd.DataFrame({0: dti, 1: tdi}) + expected = pd.DataFrame({0: dti + tdi, + 1: tdi + tdi}) + tm.assert_frame_equal(result, expected) + def test_df_add_flex_filled_mixed_dtypes(self): # GH#19611 dti = pd.date_range('2016-01-01', periods=3) From f31407c7ad778d64e8b09a373b63513d6f45c7cf Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Thu, 13 Sep 2018 09:46:12 -0700 Subject: [PATCH 2/2] fixup typos --- pandas/tests/frame/test_arithmetic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index dc41c563d9424..9c61f13b944ea 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -105,7 +105,9 @@ def test_df_add_td64_columnwise(self): dti = pd.date_range('2016-01-01', periods=10) tdi = pd.timedelta_range('1', periods=10) tser = pd.Series(tdi) - result = pd.DataFrame({0: dti, 1: tdi}) + df = pd.DataFrame({0: dti, 1: tdi}) + + result = df.add(tser, axis=0) expected = pd.DataFrame({0: dti + tdi, 1: tdi + tdi}) tm.assert_frame_equal(result, expected)