Skip to content

DOC: expanded signatures for reindex, rename and reindex_axis #15839

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2819,9 +2819,11 @@ def align(self, other, join='outer', axis=None, level=None, copy=True,
broadcast_axis=broadcast_axis)

@Appender(_shared_docs['reindex'] % _shared_doc_kwargs)
def reindex(self, index=None, columns=None, **kwargs):
def reindex(self, index=None, columns=None, method=None, level=None, copy=True,
limit=None, tolerance=None, fill_value=np.nan):
return super(DataFrame, self).reindex(index=index, columns=columns,
**kwargs)
method=method, level=level, copy=copy,
limit=limit, tolerance=tolerance, fill_value=fill_value)

@Appender(_shared_docs['reindex_axis'] % _shared_doc_kwargs)
def reindex_axis(self, labels, axis=0, method=None, level=None, copy=True,
Expand All @@ -2832,9 +2834,9 @@ def reindex_axis(self, labels, axis=0, method=None, level=None, copy=True,
limit=limit, fill_value=fill_value)

@Appender(_shared_docs['rename'] % _shared_doc_kwargs)
def rename(self, index=None, columns=None, **kwargs):
def rename(self, index=None, columns=None, copy=True, inplace=False):
return super(DataFrame, self).rename(index=index, columns=columns,
**kwargs)
copy=copy, inplace=inplace)

@Appender(_shared_docs['fillna'] % _shared_doc_kwargs)
def fillna(self, value=None, method=None, axis=None, inplace=False,
Expand Down
11 changes: 7 additions & 4 deletions pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,22 +1160,25 @@ def _wrap_result(self, result, axis):
return self._construct_return_type(result, axes)

@Appender(_shared_docs['reindex'] % _shared_doc_kwargs)
def reindex(self, items=None, major_axis=None, minor_axis=None, **kwargs):
def reindex(self, items=None, major_axis=None, minor_axis=None, method=None,
level=None, copy=True, limit=None, tolerance=None, fill_value=np.nan):
major_axis = (major_axis if major_axis is not None else
kwargs.pop('major', None))
minor_axis = (minor_axis if minor_axis is not None else
kwargs.pop('minor', None))
return super(Panel, self).reindex(items=items, major_axis=major_axis,
minor_axis=minor_axis, **kwargs)
minor_axis=minor_axis, method=None,
level=level, copy=copy, limit=limit,
tolerance=tolerance, fill_value=fill_value)

@Appender(_shared_docs['rename'] % _shared_doc_kwargs)
def rename(self, items=None, major_axis=None, minor_axis=None, **kwargs):
def rename(self, items=None, major_axis=None, minor_axis=None, copy=True, inplace=False):
major_axis = (major_axis if major_axis is not None else
kwargs.pop('major', None))
minor_axis = (minor_axis if minor_axis is not None else
kwargs.pop('minor', None))
return super(Panel, self).rename(items=items, major_axis=major_axis,
minor_axis=minor_axis, **kwargs)
minor_axis=minor_axis, copy=copy, inplace=inplace)

@Appender(_shared_docs['reindex_axis'] % _shared_doc_kwargs)
def reindex_axis(self, labels, axis=0, method=None, level=None, copy=True,
Expand Down
17 changes: 11 additions & 6 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2301,19 +2301,22 @@ def align(self, other, join='outer', axis=None, level=None, copy=True,
broadcast_axis=broadcast_axis)

@Appender(generic._shared_docs['rename'] % _shared_doc_kwargs)
def rename(self, index=None, **kwargs):
def rename(self, index=None, copy=True, inplace=False):
kwargs['inplace'] = validate_bool_kwarg(kwargs.get('inplace', False),
'inplace')

non_mapping = is_scalar(index) or (is_list_like(index) and
not is_dict_like(index))
if non_mapping:
return self._set_name(index, inplace=kwargs.get('inplace'))
return super(Series, self).rename(index=index, **kwargs)
return super(Series, self).rename(index=index, copy=copy, inplace=inplace)

@Appender(generic._shared_docs['reindex'] % _shared_doc_kwargs)
def reindex(self, index=None, **kwargs):
return super(Series, self).reindex(index=index, **kwargs)
def reindex(self, index=None, method=None, level=None, copy=True,
limit=None, tolerance=None, fill_value=np.nan):
return super(Series, self).reindex(index=index, method=method, level=level,
copy=copy, limit=limit,
tolerance=tolerance, fill_value=fill_value)

@Appender(generic._shared_docs['fillna'] % _shared_doc_kwargs)
def fillna(self, value=None, method=None, axis=None, inplace=False,
Expand All @@ -2327,11 +2330,13 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
def shift(self, periods=1, freq=None, axis=0):
return super(Series, self).shift(periods=periods, freq=freq, axis=axis)

def reindex_axis(self, labels, axis=0, **kwargs):
def reindex_axis(self, labels, axis=0, method=None, level=None, copy=True, limit=None, fill_value=np.nan):
""" for compatibility with higher dims """
if axis != 0:
raise ValueError("cannot reindex series on non-zero axis!")
return self.reindex(index=labels, **kwargs)
return self.reindex(index=labels, axis=axis,
method=method, level=level, copy=copy,
limit=limit, fill_value=fill_value)

def memory_usage(self, index=True, deep=False):
"""Memory usage of the Series
Expand Down