-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Remove Panel References #26287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Panel References #26287
Changes from 2 commits
4f4720b
bc30088
f7b0678
d5bf221
39e46b3
c4cd707
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -368,9 +368,7 @@ def _constructor(self): | |
|
||
@property | ||
def _constructor_expanddim(self): | ||
# TODO: Raise NotImplementedError or change note in extending.rst | ||
from pandas.core.panel import Panel | ||
return Panel | ||
raise NotImplementedError("Not supported for DataFrames!") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The TODO mentions changing the docs extending.rst but that looks to have already been done |
||
|
||
# ---------------------------------------------------------------------- | ||
# Constructors | ||
|
@@ -1934,22 +1932,6 @@ def to_sparse(self, fill_value=None, kind='block'): | |
columns=self.columns, default_kind=kind, | ||
default_fill_value=fill_value) | ||
|
||
def to_panel(self): | ||
""" | ||
Transform long (stacked) format (DataFrame) into wide (3D, Panel) | ||
format. | ||
|
||
.. deprecated:: 0.20.0 | ||
|
||
Currently the index of the DataFrame must be a 2-level MultiIndex. This | ||
may be generalized later | ||
|
||
Returns | ||
------- | ||
Panel | ||
""" | ||
raise NotImplementedError("Panel is being removed in pandas 0.25.0.") | ||
|
||
@deprecate_kwarg(old_arg_name='encoding', new_arg_name=None) | ||
def to_stata(self, fname, convert_dates=None, write_index=True, | ||
encoding="latin-1", byteorder=None, time_stamp=None, | ||
|
@@ -6630,8 +6612,7 @@ def append(self, other, ignore_index=False, | |
|
||
See Also | ||
-------- | ||
concat : General function to concatenate DataFrame, Series | ||
or Panel objects. | ||
concat : General function to concatenate DataFrame or Series objects. | ||
|
||
Notes | ||
----- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
is_dict_like, is_extension_array_dtype, is_integer, is_list_like, | ||
is_number, is_numeric_dtype, is_object_dtype, is_period_arraylike, | ||
is_re_compilable, is_scalar, is_timedelta64_dtype, pandas_dtype) | ||
from pandas.core.dtypes.generic import ABCDataFrame, ABCPanel, ABCSeries | ||
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries | ||
from pandas.core.dtypes.inference import is_hashable | ||
from pandas.core.dtypes.missing import isna, notna | ||
|
||
|
@@ -978,7 +978,7 @@ def rename(self, *args, **kwargs): | |
---------- | ||
%(axes)s : scalar, list-like, dict-like or function, optional | ||
Scalar or list-like will alter the ``Series.name`` attribute, | ||
and raise on DataFrame or Panel. | ||
and raise on DataFrame. | ||
dict-like or functions are transformations to apply to | ||
that axis' values | ||
copy : bool, default True | ||
|
@@ -1852,16 +1852,14 @@ def __iter__(self): | |
def keys(self): | ||
"""Get the 'info axis' (see Indexing for more) | ||
|
||
This is index for Series, columns for DataFrame and major_axis for | ||
Panel. | ||
This is index for Series, columns for DataFrame. | ||
""" | ||
return self._info_axis | ||
|
||
def iteritems(self): | ||
"""Iterate over (label, values) on info axis | ||
|
||
This is index for Series, columns for DataFrame, major_axis for Panel, | ||
and so on. | ||
This is index for Series, columns for DataFrame and so on. | ||
""" | ||
for h in self._info_axis: | ||
yield h, self[h] | ||
|
@@ -3063,8 +3061,9 @@ def _create_indexer(cls, name, indexer): | |
|
||
def get(self, key, default=None): | ||
""" | ||
Get item from object for given key (DataFrame column, Panel slice, | ||
etc.). Returns default value if not found. | ||
Get item from object for given key (ex: DataFrame column). | ||
|
||
Returns default value if not found. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -4091,8 +4090,7 @@ def sort_values(self, by=None, axis=0, ascending=True, inplace=False, | |
0 A 2 0 | ||
1 A 1 1 | ||
""" | ||
raise NotImplementedError("sort_values has not been implemented " | ||
"on Panel or Panel4D objects.") | ||
raise NotImplementedError("sort_values has not been implemented.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is now never hit, should this be AbstractMethodError? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea I think could go for that too |
||
|
||
def sort_index(self, axis=0, level=None, ascending=True, inplace=False, | ||
kind='quicksort', na_position='last', sort_remaining=True): | ||
|
@@ -4770,7 +4768,7 @@ def sample(self, n=None, frac=None, replace=False, weights=None, | |
object. | ||
axis : int or string, optional | ||
Axis to sample. Accepts axis number or name. Default is stat axis | ||
for given data type (0 for Series and DataFrames, 1 for Panels). | ||
for given data type (0 for Series and DataFrames). | ||
|
||
Returns | ||
------- | ||
|
@@ -4853,7 +4851,7 @@ def sample(self, n=None, frac=None, replace=False, weights=None, | |
"a DataFrame") | ||
else: | ||
raise ValueError("Strings cannot be passed as weights " | ||
"when sampling from a Series or Panel.") | ||
"when sampling from a Series.") | ||
|
||
weights = pd.Series(weights, dtype='float64') | ||
|
||
|
@@ -5697,8 +5695,7 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs): | |
elif self.ndim > 2: | ||
raise NotImplementedError( | ||
'astype() only accepts a dtype arg of type dict when ' | ||
'invoked on Series and DataFrames. A single dtype must be ' | ||
'specified when invoked on a Panel.' | ||
'invoked on Series and DataFrames.' | ||
) | ||
for col_name in dtype.keys(): | ||
if col_name not in self: | ||
|
@@ -5751,7 +5748,7 @@ def copy(self, deep=True): | |
|
||
Returns | ||
------- | ||
copy : Series, DataFrame or Panel | ||
copy : Series or DataFrame | ||
Object type matches caller. | ||
|
||
Notes | ||
|
@@ -6822,8 +6819,7 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False, | |
inplace = validate_bool_kwarg(inplace, 'inplace') | ||
|
||
if self.ndim > 2: | ||
raise NotImplementedError("Interpolate has not been implemented " | ||
"on Panel and Panel 4D objects.") | ||
raise NotImplementedError("Interpolate has not been implemented ") | ||
|
||
if axis == 0: | ||
ax = self._info_axis_name | ||
|
@@ -7326,9 +7322,6 @@ def clip(self, lower=None, upper=None, axis=None, inplace=False, | |
3 6 8 | ||
4 5 3 | ||
""" | ||
if isinstance(self, ABCPanel): | ||
raise NotImplementedError("clip is not supported yet for panels") | ||
|
||
inplace = validate_bool_kwarg(inplace, 'inplace') | ||
|
||
axis = nv.validate_clip_with_axis(axis, args, kwargs) | ||
|
@@ -8348,8 +8341,7 @@ def rank(self, axis=0, method='average', numeric_only=None, | |
* first: ranks assigned in order they appear in the array | ||
* dense: like 'min', but rank always increases by 1 between groups | ||
numeric_only : boolean, default None | ||
Include only float, int, boolean data. Valid only for DataFrame or | ||
Panel objects | ||
Include only float, int, boolean data. Valid only for DataFrames. | ||
na_option : {'keep', 'top', 'bottom'} | ||
* keep: leave NA values where they are | ||
* top: smallest rank if ascending | ||
|
@@ -9773,10 +9765,7 @@ def describe(self, percentiles=None, include=None, exclude=None): | |
75% NaN 2.5 | ||
max NaN 3.0 | ||
""" | ||
if self.ndim >= 3: | ||
msg = "describe is not implemented on Panel objects." | ||
raise NotImplementedError(msg) | ||
elif self.ndim == 2 and self.columns.size == 0: | ||
if self.ndim == 2 and self.columns.size == 0: | ||
raise ValueError("Cannot describe a DataFrame without columns") | ||
|
||
if percentiles is not None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This previously was only modifying the exception message for Panel objects before raising again, so I simplified to just remove the try...except altogether and let it raise as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it’s a one liner now, Is this still needed as a separate function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea could probably just call this directly now; I'll give it a look tonight and repush