Skip to content

Commit ed5a4e8

Browse files
committed
API: deprecate broadcasting TimeSeries across datetime indexed DataFrame index by default #2304
1 parent c01d1bc commit ed5a4e8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pandas/core/frame.py

+5
Original file line numberDiff line numberDiff line change
@@ -3438,6 +3438,11 @@ def _combine_series_infer(self, other, func, fill_value=None):
34383438

34393439
# teeny hack because one does DataFrame + TimeSeries all the time
34403440
if self.index.is_all_dates and other.index.is_all_dates:
3441+
import warnings
3442+
warnings.warn(("TimeSeries broadcasting across DataFrame index "
3443+
"by default is deprecated. Please use "
3444+
"DataFrame.sub"),
3445+
FutureWarning)
34413446
return self._combine_match_index(other, func, fill_value)
34423447
else:
34433448
return self._combine_match_columns(other, func, fill_value)

pandas/tests/test_frame.py

+7
Original file line numberDiff line numberDiff line change
@@ -3459,6 +3459,11 @@ def test_combineSeries(self):
34593459
self.assert_(np.isnan(larger_added['E']).all())
34603460

34613461
# TimeSeries
3462+
import sys
3463+
3464+
buf = StringIO()
3465+
sys.stderr = buf
3466+
34623467
ts = self.tsframe['A']
34633468
added = self.tsframe + ts
34643469

@@ -3474,6 +3479,8 @@ def test_combineSeries(self):
34743479
smaller_added2 = self.tsframe + smaller_ts
34753480
assert_frame_equal(smaller_added, smaller_added2)
34763481

3482+
sys.stderr = sys.__stderr__
3483+
34773484
# length 0
34783485
result = self.tsframe + ts[:0]
34793486

0 commit comments

Comments
 (0)