Skip to content

Commit

Permalink
Merge pull request #10892 from jreback/depr2
Browse files Browse the repository at this point in the history
DEPR: Bunch o deprecation removals part 2
  • Loading branch information
jreback committed Aug 24, 2015
2 parents 78f3c80 + 0774b57 commit a77956d
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 198 deletions.
10 changes: 10 additions & 0 deletions doc/source/whatsnew/v0.17.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ Deprecations
``DataFrame.add(other, fill_value=0)`` and ``DataFrame.mul(other, fill_value=1.)``
(:issue:`10735`).
- ``TimeSeries`` deprecated in favor of ``Series`` (note that this has been alias since 0.13.0), (:issue:`10890`)
- ``WidePanel`` deprecated in favor of ``Panel``, ``LongPanel`` in favor of ``DataFrame`` (note these have been aliases since < 0.11.0), (:issue:`10892`)

.. _whatsnew_0170.prior_deprecations:

Expand Down Expand Up @@ -705,6 +706,15 @@ Removal of prior version deprecations/changes

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




- Remove ``table`` keyword in ``HDFStore.put/append``, in favor of using ``format=`` (:issue:`4645`)
- Remove ``kind`` in ``read_excel/ExcelFile`` as its unused (:issue:`4712`)
- Remove ``infer_type`` keyword from ``pd.read_html`` as its unused (:issue:`4770`, :issue:`7032`)
- Remove ``offset`` and ``timeRule`` keywords from ``Series.tshift/shift``, in favor of ``freq`` (:issue:`4853`, :issue:`4864`)
- Remove ``pd.load/pd.save`` aliases in favor of ``pd.to_pickle/pd.read_pickle`` (:issue:`3787`)

.. _whatsnew_0170.performance:

Performance Improvements
Expand Down
5 changes: 1 addition & 4 deletions pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@

from pandas.core.series import Series, TimeSeries
from pandas.core.frame import DataFrame
from pandas.core.panel import Panel
from pandas.core.panel import Panel, WidePanel
from pandas.core.panel4d import Panel4D
from pandas.core.groupby import groupby
from pandas.core.reshape import (pivot_simple as pivot, get_dummies,
lreshape, wide_to_long)

WidePanel = Panel

from pandas.core.indexing import IndexSlice
from pandas.tseries.offsets import DateOffset
from pandas.tseries.tools import to_datetime
Expand All @@ -29,7 +27,6 @@
from pandas.tseries.period import Period, PeriodIndex

# legacy
from pandas.core.common import save, load # deprecated, remove in 0.13
import pandas.core.datetools as datetools

from pandas.core.config import (get_option, set_option, reset_option,
Expand Down
40 changes: 0 additions & 40 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3313,46 +3313,6 @@ def console_encode(object, **kwds):
return pprint_thing_encoded(object,
get_option("display.encoding"))


def load(path): # TODO remove in 0.13
"""
Load pickled pandas object (or any other pickled object) from the specified
file path
Warning: Loading pickled data received from untrusted sources can be
unsafe. See: http://docs.python.org/2.7/library/pickle.html
Parameters
----------
path : string
File path
Returns
-------
unpickled : type of object stored in file
"""
import warnings
warnings.warn("load is deprecated, use read_pickle", FutureWarning)
from pandas.io.pickle import read_pickle
return read_pickle(path)


def save(obj, path): # TODO remove in 0.13
"""
Pickle (serialize) object to input file path
Parameters
----------
obj : any object
path : string
File path
"""
import warnings
warnings.warn("save is deprecated, use obj.to_pickle", FutureWarning)
from pandas.io.pickle import to_pickle
return to_pickle(obj, path)


def _maybe_match_name(a, b):
a_has = hasattr(a, 'name')
b_has = hasattr(b, 'name')
Expand Down
20 changes: 0 additions & 20 deletions pandas/core/datetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,3 @@
isBusinessDay = BDay().onOffset
isMonthEnd = MonthEnd().onOffset
isBMonthEnd = BMonthEnd().onOffset


def _resolve_offset(freq, kwds):
if 'timeRule' in kwds or 'offset' in kwds:
offset = kwds.get('offset', None)
offset = kwds.get('timeRule', offset)
if isinstance(offset, compat.string_types):
offset = getOffset(offset)
warn = True
else:
offset = freq
warn = False

if warn:
import warnings
warnings.warn("'timeRule' and 'offset' parameters are deprecated,"
" please use 'freq' instead",
FutureWarning)

return offset
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2618,9 +2618,9 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
**kwargs)

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

def set_index(self, keys, drop=True, append=False, inplace=False,
verify_integrity=False):
Expand Down
37 changes: 10 additions & 27 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,20 +1006,6 @@ def to_pickle(self, path):
from pandas.io.pickle import to_pickle
return to_pickle(self, path)

def save(self, path): # TODO remove in 0.14
"Deprecated. Use to_pickle instead"
import warnings
from pandas.io.pickle import to_pickle
warnings.warn("save is deprecated, use to_pickle", FutureWarning)
return to_pickle(self, path)

def load(self, path): # TODO remove in 0.14
"Deprecated. Use read_pickle instead."
import warnings
from pandas.io.pickle import read_pickle
warnings.warn("load is deprecated, use pd.read_pickle", FutureWarning)
return read_pickle(path)

def to_clipboard(self, excel=None, sep=None, **kwargs):
"""
Attempt to write text representation of object to the system clipboard
Expand Down Expand Up @@ -3806,15 +3792,15 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
shifted : %(klass)s
""")
@Appender(_shared_docs['shift'] % _shared_doc_kwargs)
def shift(self, periods=1, freq=None, axis=0, **kwargs):
def shift(self, periods=1, freq=None, axis=0):
if periods == 0:
return self

block_axis = self._get_block_manager_axis(axis)
if freq is None and not len(kwargs):
if freq is None:
new_data = self._data.shift(periods=periods, axis=block_axis)
else:
return self.tshift(periods, freq, **kwargs)
return self.tshift(periods, freq)

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

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

return new_obj.__finalize__(self)

def tshift(self, periods=1, freq=None, axis=0, **kwargs):
def tshift(self, periods=1, freq=None, axis=0):
"""
Shift the time index, using the index's frequency if available
Expand All @@ -3877,7 +3863,6 @@ def tshift(self, periods=1, freq=None, axis=0, **kwargs):
-------
shifted : NDFrame
"""
from pandas.core.datetools import _resolve_offset

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

offset = _resolve_offset(freq, kwargs)

if isinstance(offset, string_types):
offset = datetools.to_offset(offset)
if isinstance(freq, string_types):
freq = datetools.to_offset(freq)

block_axis = self._get_block_manager_axis(axis)
if isinstance(index, PeriodIndex):
orig_offset = datetools.to_offset(index.freq)
if offset == orig_offset:
orig_freq = datetools.to_offset(index.freq)
if freq == orig_freq:
new_data = self._data.copy()
new_data.axes[block_axis] = index.shift(periods)
else:
msg = ('Given freq %s does not match PeriodIndex freq %s' %
(offset.rule_code, orig_offset.rule_code))
(freq.rule_code, orig_freq.rule_code))
raise ValueError(msg)
else:
new_data = self._data.copy()
new_data.axes[block_axis] = index.shift(periods, offset)
new_data.axes[block_axis] = index.shift(periods, freq)

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

Expand Down
26 changes: 22 additions & 4 deletions pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,8 +1210,8 @@ def shift(self, periods=1, freq=None, axis='major'):

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

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

def join(self, other, how='left', lsuffix='', rsuffix=''):
"""
Expand Down Expand Up @@ -1509,5 +1509,23 @@ def f(self, other, axis=0):
Panel._add_aggregate_operations()
Panel._add_numeric_operations()

WidePanel = Panel
LongPanel = DataFrame
# legacy
class WidePanel(Panel):

def __init__(self, *args, **kwargs):

# deprecation, #10892
warnings.warn("WidePanel is deprecated. Please use Panel",
FutureWarning, stacklevel=2)

super(WidePanel, self).__init__(*args, **kwargs)

class LongPanel(DataFrame):

def __init__(self, *args, **kwargs):

# deprecation, #10892
warnings.warn("LongPanel is deprecated. Please use DataFrame",
FutureWarning, stacklevel=2)

super(LongPanel, self).__init__(*args, **kwargs)
4 changes: 2 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2182,9 +2182,9 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
**kwargs)

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

def reindex_axis(self, labels, axis=0, **kwargs):
""" for compatibility with higher dims """
Expand Down
Loading

0 comments on commit a77956d

Please sign in to comment.