Skip to content

Commit 81675b6

Browse files
committed
BUG: Change Panel.shift to use slice_shift pandas-dev#6605 pandas-dev#6826
TST: Make sure Panel.shift retains dtypes DOC: removed previous doc entries for pandas-dev#6605 Re-add note about dropping shifted periods DOC: added note about bug fix don't pass on freq
1 parent 5e7bf20 commit 81675b6

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

doc/source/release.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ API Changes
151151
to a non-unique item in the ``Index`` (previously raised a ``KeyError``). (:issue:`6738`)
152152
- all offset operations now return ``Timestamp`` types (rather than datetime), Business/Week frequencies were incorrect (:issue:`4069`)
153153
- ``Series.iteritems()`` is now lazy (returns an iterator rather than a list). This was the documented behavior prior to 0.14. (:issue:`6760`)
154-
- ``Panel.shift`` now uses ``NDFrame.shift``. It no longer drops the ``nan`` data and retains its original shape. (:issue:`4867`)
155154
- ``to_excel`` now converts ``np.inf`` into a string representation,
156155
customizable by the ``inf_rep`` keyword argument (Excel has no native inf
157156
representation) (:issue:`6782`)
@@ -424,6 +423,7 @@ Bug Fixes
424423
- Bug in ``DataFrame.apply`` with functions that used *args or **kwargs and returned
425424
an empty result (:issue:`6952`)
426425
- Bug in sum/mean on 32-bit platforms on overflows (:issue:`6915`)
426+
- Moved ``Panel.shift`` to ``NDFrame.slice_shift`` and fixed to respect multiple dtypes. (:issue:`6959`)
427427
428428
pandas 0.13.1
429429
-------------

doc/source/v0.14.0.txt

-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ API changes
199199
covs[df.index[-1]]
200200

201201
- ``Series.iteritems()`` is now lazy (returns an iterator rather than a list). This was the documented behavior prior to 0.14. (:issue:`6760`)
202-
- ``Panel.shift`` now uses ``NDFrame.shift``. It no longer drops the ``nan`` data and retains its original shape. (:issue:`4867`)
203202

204203
- Added ``nunique`` and ``value_counts`` functions to ``Index`` for counting unique elements. (:issue:`6734`)
205204
- ``stack`` and ``unstack`` now raise a ``ValueError`` when the ``level`` keyword refers

pandas/core/panel.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,8 @@ def count(self, axis='major'):
11541154
@deprecate_kwarg(old_arg_name='lags', new_arg_name='periods')
11551155
def shift(self, periods=1, freq=None, axis='major'):
11561156
"""
1157-
Shift major or minor axis by specified number of leads/lags.
1157+
Shift major or minor axis by specified number of leads/lags. Drops
1158+
periods right now compared with DataFrame.shift
11581159
11591160
Parameters
11601161
----------
@@ -1171,7 +1172,7 @@ def shift(self, periods=1, freq=None, axis='major'):
11711172
if axis == 'items':
11721173
raise ValueError('Invalid axis')
11731174

1174-
return super(Panel, self).shift(periods, freq=freq, axis=axis)
1175+
return super(Panel, self).slice_shift(periods, axis=axis)
11751176

11761177
def tshift(self, periods=1, freq=None, axis='major', **kwds):
11771178
return super(Panel, self).tshift(periods, freq, axis, **kwds)

pandas/tests/test_panel.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
assert_almost_equal,
2222
ensure_clean,
2323
assertRaisesRegexp,
24-
makeCustomDataframe as mkdf
24+
makeCustomDataframe as mkdf,
25+
makeMixedDataFrame
2526
)
2627
import pandas.core.panel as panelm
2728
import pandas.util.testing as tm
@@ -1652,10 +1653,17 @@ def test_shift(self):
16521653

16531654
# negative numbers, #2164
16541655
result = self.panel.shift(-1)
1655-
expected = Panel(dict((i, f.shift(-1))
1656+
expected = Panel(dict((i, f.shift(-1)[:-1])
16561657
for i, f in compat.iteritems(self.panel)))
16571658
assert_panel_equal(result, expected)
16581659

1660+
# mixed dtypes #6959
1661+
data = [('item '+ch, makeMixedDataFrame()) for ch in list('abcde')]
1662+
data = dict(data)
1663+
mixed_panel = Panel.from_dict(data, orient='minor')
1664+
shifted = mixed_panel.shift(1)
1665+
assert_series_equal(mixed_panel.dtypes, shifted.dtypes)
1666+
16591667
def test_tshift(self):
16601668
# PeriodIndex
16611669
ps = tm.makePeriodPanel()

0 commit comments

Comments
 (0)