Skip to content

Commit

Permalink
API: deprecate broadcasting TimeSeries across datetime indexed DataFr…
Browse files Browse the repository at this point in the history
…ame index by default #2304
  • Loading branch information
changhiskhan committed Nov 24, 2012
1 parent c01d1bc commit ed5a4e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3438,6 +3438,11 @@ def _combine_series_infer(self, other, func, fill_value=None):

# teeny hack because one does DataFrame + TimeSeries all the time
if self.index.is_all_dates and other.index.is_all_dates:
import warnings
warnings.warn(("TimeSeries broadcasting across DataFrame index "
"by default is deprecated. Please use "
"DataFrame.sub"),

This comment has been minimized.

Copy link
@wesm

wesm Nov 24, 2012

Member

Well, or mul, add, div, pow, ...

FutureWarning)
return self._combine_match_index(other, func, fill_value)
else:
return self._combine_match_columns(other, func, fill_value)
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3459,6 +3459,11 @@ def test_combineSeries(self):
self.assert_(np.isnan(larger_added['E']).all())

# TimeSeries
import sys

buf = StringIO()
sys.stderr = buf

ts = self.tsframe['A']
added = self.tsframe + ts

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

sys.stderr = sys.__stderr__

# length 0
result = self.tsframe + ts[:0]

Expand Down

0 comments on commit ed5a4e8

Please sign in to comment.