-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: remove unused NDFrame methods #30935
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
Changes from 2 commits
df5827f
b428caf
1ce8b9e
6e244e9
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 |
---|---|---|
|
@@ -346,13 +346,6 @@ def _construct_axes_dict(self, axes=None, **kwargs): | |
d.update(kwargs) | ||
return d | ||
|
||
@staticmethod | ||
def _construct_axes_dict_from(self, axes, **kwargs): | ||
"""Return an axes dictionary for the passed axes.""" | ||
d = {a: ax for a, ax in zip(self._AXIS_ORDERS, axes)} | ||
d.update(kwargs) | ||
return d | ||
|
||
def _construct_axes_from_arguments( | ||
self, args, kwargs, require_all: bool = False, sentinel=None | ||
): | ||
|
@@ -381,18 +374,6 @@ def _construct_axes_from_arguments( | |
axes = {a: kwargs.pop(a, sentinel) for a in self._AXIS_ORDERS} | ||
return axes, kwargs | ||
|
||
@classmethod | ||
def _from_axes(cls: Type[FrameOrSeries], data, axes, **kwargs) -> FrameOrSeries: | ||
# for construction from BlockManager | ||
if isinstance(data, BlockManager): | ||
return cls(data, **kwargs) | ||
else: | ||
if cls._AXIS_REVERSED: | ||
axes = axes[::-1] | ||
d = cls._construct_axes_dict_from(cls, axes, copy=False) | ||
d.update(kwargs) | ||
return cls(data, **d) | ||
|
||
@classmethod | ||
def _get_axis_number(cls, axis): | ||
axis = cls._AXIS_ALIASES.get(axis, axis) | ||
|
@@ -908,23 +889,7 @@ def squeeze(self, axis=None): | |
] | ||
|
||
def swaplevel(self: FrameOrSeries, i=-2, j=-1, axis=0) -> FrameOrSeries: | ||
""" | ||
Swap levels i and j in a MultiIndex on a particular axis | ||
|
||
Parameters | ||
---------- | ||
i, j : int, str (can be mixed) | ||
Level of index to be swapped. Can pass level name as string. | ||
|
||
Returns | ||
------- | ||
swapped : same type as caller (new object) | ||
""" | ||
axis = self._get_axis_number(axis) | ||
result = self.copy() | ||
labels = result._data.axes[axis] | ||
result._data.set_axis(axis, labels.swaplevel(i, j)) | ||
return result | ||
raise AbstractMethodError(self) | ||
|
||
# ---------------------------------------------------------------------- | ||
# Rename | ||
|
@@ -4268,22 +4233,7 @@ def sort_index( | |
sorted_obj : DataFrame or None | ||
DataFrame with sorted index if inplace=False, None otherwise. | ||
""" | ||
inplace = validate_bool_kwarg(inplace, "inplace") | ||
axis = self._get_axis_number(axis) | ||
axis_name = self._get_axis_name(axis) | ||
labels = self._get_axis(axis) | ||
|
||
if level is not None: | ||
raise NotImplementedError("level is not implemented") | ||
if inplace: | ||
raise NotImplementedError("inplace is not implemented") | ||
|
||
sort_index = labels.argsort() | ||
if not ascending: | ||
sort_index = sort_index[::-1] | ||
|
||
new_axis = labels.take(sort_index) | ||
return self.reindex(**{axis_name: new_axis}) | ||
raise AbstractMethodError(self) | ||
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. Rationale? 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. actually can you just remove this entirely? its defined in both series/frame with doc-strings. |
||
|
||
def reindex(self: FrameOrSeries, *args, **kwargs) -> FrameOrSeries: | ||
""" | ||
|
@@ -5367,11 +5317,6 @@ def _is_numeric_mixed_type(self): | |
f = lambda: self._data.is_numeric_mixed_type | ||
return self._protect_consolidate(f) | ||
|
||
@property | ||
def _is_datelike_mixed_type(self): | ||
f = lambda: self._data.is_datelike_mixed_type | ||
return self._protect_consolidate(f) | ||
|
||
def _check_inplace_setting(self, value) -> bool_t: | ||
""" check whether we allow in-place setting with this type of value """ | ||
|
||
|
@@ -5480,11 +5425,6 @@ def _values(self) -> np.ndarray: | |
"""internal implementation""" | ||
return self.values | ||
|
||
@property | ||
def _get_values(self) -> np.ndarray: | ||
# compat | ||
return self.values | ||
|
||
def _internal_get_values(self) -> np.ndarray: | ||
""" | ||
Return an ndarray after converting sparse values to dense. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -548,9 +548,6 @@ def test_validate_bool_args(self): | |
with pytest.raises(ValueError): | ||
super(DataFrame, df).drop("a", axis=1, inplace=value) | ||
|
||
with pytest.raises(ValueError): | ||
super(DataFrame, df).sort_index(inplace=value) | ||
|
||
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. Why is this being dropped? 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. I guess this would technically raise an AbstractMethodError now; indifferent on whether should update the error or keep removed But would be nice to update this test for Python3 super calls and parametrization |
||
with pytest.raises(ValueError): | ||
super(DataFrame, df)._consolidate(inplace=value) | ||
|
||
|
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.
Rationale?
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.
is it because of the additional copy parameter in Series.swaplevel that the generic method cannot retained and frame and series call super in preference to removing the generic implementation.
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.
can this be removed entirely?