Skip to content

Commit a77956d

Browse files
committed
Merge pull request pandas-dev#10892 from jreback/depr2
DEPR: Bunch o deprecation removals part 2
2 parents 78f3c80 + 0774b57 commit a77956d

File tree

15 files changed

+112
-198
lines changed

15 files changed

+112
-198
lines changed

doc/source/whatsnew/v0.17.0.txt

+10
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ Deprecations
665665
``DataFrame.add(other, fill_value=0)`` and ``DataFrame.mul(other, fill_value=1.)``
666666
(:issue:`10735`).
667667
- ``TimeSeries`` deprecated in favor of ``Series`` (note that this has been alias since 0.13.0), (:issue:`10890`)
668+
- ``WidePanel`` deprecated in favor of ``Panel``, ``LongPanel`` in favor of ``DataFrame`` (note these have been aliases since < 0.11.0), (:issue:`10892`)
668669

669670
.. _whatsnew_0170.prior_deprecations:
670671

@@ -705,6 +706,15 @@ Removal of prior version deprecations/changes
705706

706707
df.add(df.A,axis='index')
707708

709+
710+
711+
712+
- Remove ``table`` keyword in ``HDFStore.put/append``, in favor of using ``format=`` (:issue:`4645`)
713+
- Remove ``kind`` in ``read_excel/ExcelFile`` as its unused (:issue:`4712`)
714+
- Remove ``infer_type`` keyword from ``pd.read_html`` as its unused (:issue:`4770`, :issue:`7032`)
715+
- Remove ``offset`` and ``timeRule`` keywords from ``Series.tshift/shift``, in favor of ``freq`` (:issue:`4853`, :issue:`4864`)
716+
- Remove ``pd.load/pd.save`` aliases in favor of ``pd.to_pickle/pd.read_pickle`` (:issue:`3787`)
717+
708718
.. _whatsnew_0170.performance:
709719

710720
Performance Improvements

pandas/core/api.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212

1313
from pandas.core.series import Series, TimeSeries
1414
from pandas.core.frame import DataFrame
15-
from pandas.core.panel import Panel
15+
from pandas.core.panel import Panel, WidePanel
1616
from pandas.core.panel4d import Panel4D
1717
from pandas.core.groupby import groupby
1818
from pandas.core.reshape import (pivot_simple as pivot, get_dummies,
1919
lreshape, wide_to_long)
2020

21-
WidePanel = Panel
22-
2321
from pandas.core.indexing import IndexSlice
2422
from pandas.tseries.offsets import DateOffset
2523
from pandas.tseries.tools import to_datetime
@@ -29,7 +27,6 @@
2927
from pandas.tseries.period import Period, PeriodIndex
3028

3129
# legacy
32-
from pandas.core.common import save, load # deprecated, remove in 0.13
3330
import pandas.core.datetools as datetools
3431

3532
from pandas.core.config import (get_option, set_option, reset_option,

pandas/core/common.py

-40
Original file line numberDiff line numberDiff line change
@@ -3313,46 +3313,6 @@ def console_encode(object, **kwds):
33133313
return pprint_thing_encoded(object,
33143314
get_option("display.encoding"))
33153315

3316-
3317-
def load(path): # TODO remove in 0.13
3318-
"""
3319-
Load pickled pandas object (or any other pickled object) from the specified
3320-
file path
3321-
3322-
Warning: Loading pickled data received from untrusted sources can be
3323-
unsafe. See: http://docs.python.org/2.7/library/pickle.html
3324-
3325-
Parameters
3326-
----------
3327-
path : string
3328-
File path
3329-
3330-
Returns
3331-
-------
3332-
unpickled : type of object stored in file
3333-
"""
3334-
import warnings
3335-
warnings.warn("load is deprecated, use read_pickle", FutureWarning)
3336-
from pandas.io.pickle import read_pickle
3337-
return read_pickle(path)
3338-
3339-
3340-
def save(obj, path): # TODO remove in 0.13
3341-
"""
3342-
Pickle (serialize) object to input file path
3343-
3344-
Parameters
3345-
----------
3346-
obj : any object
3347-
path : string
3348-
File path
3349-
"""
3350-
import warnings
3351-
warnings.warn("save is deprecated, use obj.to_pickle", FutureWarning)
3352-
from pandas.io.pickle import to_pickle
3353-
return to_pickle(obj, path)
3354-
3355-
33563316
def _maybe_match_name(a, b):
33573317
a_has = hasattr(a, 'name')
33583318
b_has = hasattr(b, 'name')

pandas/core/datetools.py

-20
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,3 @@
4141
isBusinessDay = BDay().onOffset
4242
isMonthEnd = MonthEnd().onOffset
4343
isBMonthEnd = BMonthEnd().onOffset
44-
45-
46-
def _resolve_offset(freq, kwds):
47-
if 'timeRule' in kwds or 'offset' in kwds:
48-
offset = kwds.get('offset', None)
49-
offset = kwds.get('timeRule', offset)
50-
if isinstance(offset, compat.string_types):
51-
offset = getOffset(offset)
52-
warn = True
53-
else:
54-
offset = freq
55-
warn = False
56-
57-
if warn:
58-
import warnings
59-
warnings.warn("'timeRule' and 'offset' parameters are deprecated,"
60-
" please use 'freq' instead",
61-
FutureWarning)
62-
63-
return offset

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2618,9 +2618,9 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
26182618
**kwargs)
26192619

26202620
@Appender(_shared_docs['shift'] % _shared_doc_kwargs)
2621-
def shift(self, periods=1, freq=None, axis=0, **kwargs):
2621+
def shift(self, periods=1, freq=None, axis=0):
26222622
return super(DataFrame, self).shift(periods=periods, freq=freq,
2623-
axis=axis, **kwargs)
2623+
axis=axis)
26242624

26252625
def set_index(self, keys, drop=True, append=False, inplace=False,
26262626
verify_integrity=False):

pandas/core/generic.py

+10-27
Original file line numberDiff line numberDiff line change
@@ -1006,20 +1006,6 @@ def to_pickle(self, path):
10061006
from pandas.io.pickle import to_pickle
10071007
return to_pickle(self, path)
10081008

1009-
def save(self, path): # TODO remove in 0.14
1010-
"Deprecated. Use to_pickle instead"
1011-
import warnings
1012-
from pandas.io.pickle import to_pickle
1013-
warnings.warn("save is deprecated, use to_pickle", FutureWarning)
1014-
return to_pickle(self, path)
1015-
1016-
def load(self, path): # TODO remove in 0.14
1017-
"Deprecated. Use read_pickle instead."
1018-
import warnings
1019-
from pandas.io.pickle import read_pickle
1020-
warnings.warn("load is deprecated, use pd.read_pickle", FutureWarning)
1021-
return read_pickle(path)
1022-
10231009
def to_clipboard(self, excel=None, sep=None, **kwargs):
10241010
"""
10251011
Attempt to write text representation of object to the system clipboard
@@ -3806,15 +3792,15 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
38063792
shifted : %(klass)s
38073793
""")
38083794
@Appender(_shared_docs['shift'] % _shared_doc_kwargs)
3809-
def shift(self, periods=1, freq=None, axis=0, **kwargs):
3795+
def shift(self, periods=1, freq=None, axis=0):
38103796
if periods == 0:
38113797
return self
38123798

38133799
block_axis = self._get_block_manager_axis(axis)
3814-
if freq is None and not len(kwargs):
3800+
if freq is None:
38153801
new_data = self._data.shift(periods=periods, axis=block_axis)
38163802
else:
3817-
return self.tshift(periods, freq, **kwargs)
3803+
return self.tshift(periods, freq)
38183804

38193805
return self._constructor(new_data).__finalize__(self)
38203806

@@ -3854,7 +3840,7 @@ def slice_shift(self, periods=1, axis=0):
38543840

38553841
return new_obj.__finalize__(self)
38563842

3857-
def tshift(self, periods=1, freq=None, axis=0, **kwargs):
3843+
def tshift(self, periods=1, freq=None, axis=0):
38583844
"""
38593845
Shift the time index, using the index's frequency if available
38603846
@@ -3877,7 +3863,6 @@ def tshift(self, periods=1, freq=None, axis=0, **kwargs):
38773863
-------
38783864
shifted : NDFrame
38793865
"""
3880-
from pandas.core.datetools import _resolve_offset
38813866

38823867
index = self._get_axis(axis)
38833868
if freq is None:
@@ -3893,24 +3878,22 @@ def tshift(self, periods=1, freq=None, axis=0, **kwargs):
38933878
if periods == 0:
38943879
return self
38953880

3896-
offset = _resolve_offset(freq, kwargs)
3897-
3898-
if isinstance(offset, string_types):
3899-
offset = datetools.to_offset(offset)
3881+
if isinstance(freq, string_types):
3882+
freq = datetools.to_offset(freq)
39003883

39013884
block_axis = self._get_block_manager_axis(axis)
39023885
if isinstance(index, PeriodIndex):
3903-
orig_offset = datetools.to_offset(index.freq)
3904-
if offset == orig_offset:
3886+
orig_freq = datetools.to_offset(index.freq)
3887+
if freq == orig_freq:
39053888
new_data = self._data.copy()
39063889
new_data.axes[block_axis] = index.shift(periods)
39073890
else:
39083891
msg = ('Given freq %s does not match PeriodIndex freq %s' %
3909-
(offset.rule_code, orig_offset.rule_code))
3892+
(freq.rule_code, orig_freq.rule_code))
39103893
raise ValueError(msg)
39113894
else:
39123895
new_data = self._data.copy()
3913-
new_data.axes[block_axis] = index.shift(periods, offset)
3896+
new_data.axes[block_axis] = index.shift(periods, freq)
39143897

39153898
return self._constructor(new_data).__finalize__(self)
39163899

pandas/core/panel.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,8 @@ def shift(self, periods=1, freq=None, axis='major'):
12101210

12111211
return super(Panel, self).slice_shift(periods, axis=axis)
12121212

1213-
def tshift(self, periods=1, freq=None, axis='major', **kwds):
1214-
return super(Panel, self).tshift(periods, freq, axis, **kwds)
1213+
def tshift(self, periods=1, freq=None, axis='major'):
1214+
return super(Panel, self).tshift(periods, freq, axis)
12151215

12161216
def join(self, other, how='left', lsuffix='', rsuffix=''):
12171217
"""
@@ -1509,5 +1509,23 @@ def f(self, other, axis=0):
15091509
Panel._add_aggregate_operations()
15101510
Panel._add_numeric_operations()
15111511

1512-
WidePanel = Panel
1513-
LongPanel = DataFrame
1512+
# legacy
1513+
class WidePanel(Panel):
1514+
1515+
def __init__(self, *args, **kwargs):
1516+
1517+
# deprecation, #10892
1518+
warnings.warn("WidePanel is deprecated. Please use Panel",
1519+
FutureWarning, stacklevel=2)
1520+
1521+
super(WidePanel, self).__init__(*args, **kwargs)
1522+
1523+
class LongPanel(DataFrame):
1524+
1525+
def __init__(self, *args, **kwargs):
1526+
1527+
# deprecation, #10892
1528+
warnings.warn("LongPanel is deprecated. Please use DataFrame",
1529+
FutureWarning, stacklevel=2)
1530+
1531+
super(LongPanel, self).__init__(*args, **kwargs)

pandas/core/series.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2182,9 +2182,9 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
21822182
**kwargs)
21832183

21842184
@Appender(generic._shared_docs['shift'] % _shared_doc_kwargs)
2185-
def shift(self, periods=1, freq=None, axis=0, **kwargs):
2185+
def shift(self, periods=1, freq=None, axis=0):
21862186
return super(Series, self).shift(periods=periods, freq=freq,
2187-
axis=axis, **kwargs)
2187+
axis=axis)
21882188

21892189
def reindex_axis(self, labels, axis=0, **kwargs):
21902190
""" for compatibility with higher dims """

0 commit comments

Comments
 (0)