Skip to content

DOC: use _shared_docs for fillna methods #10036

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

Merged
merged 1 commit into from
May 4, 2015
Merged
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: 9 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
# Docstring templates

_shared_doc_kwargs = dict(axes='index, columns', klass='DataFrame',
axes_single_arg="{0,1,'index','columns'}")
axes_single_arg="{0, 1, 'index', 'columns'}")

_numeric_only_doc = """numeric_only : boolean, default None
Include only float, int, boolean data. If None, will attempt to use
Expand Down Expand Up @@ -2515,6 +2515,14 @@ def rename(self, index=None, columns=None, **kwargs):
return super(DataFrame, self).rename(index=index, columns=columns,
**kwargs)

@Appender(_shared_docs['fillna'] % _shared_doc_kwargs)
def fillna(self, value=None, method=None, axis=None, inplace=False,
limit=None, downcast=None, **kwargs):
return super(DataFrame, self).fillna(value=value, method=method,
axis=axis, inplace=inplace,
limit=limit, downcast=downcast,
**kwargs)

def set_index(self, keys, drop=True, append=False, inplace=False,
verify_integrity=False):
"""
Expand Down
14 changes: 8 additions & 6 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2295,8 +2295,7 @@ def convert_objects(self, convert_dates=True, convert_numeric=False,
#----------------------------------------------------------------------
# Filling NA's

def fillna(self, value=None, method=None, axis=None, inplace=False,
limit=None, downcast=None):
_shared_docs['fillna'] = (
"""
Fill NA/NaN values using the specified method

Expand All @@ -2311,9 +2310,7 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
values specifying which value to use for each index (for a Series) or
column (for a DataFrame). (values not in the dict/Series/DataFrame will not be
filled). This value cannot be a list.
axis : {0, 1}, default 0
* 0: fill column-by-column
* 1: fill row-by-row
axis : %(axes_single_arg)s
inplace : boolean, default False
If True, fill in place. Note: this will modify any
other views on this object, (e.g. a no-copy slice for a column in a
Expand All @@ -2336,8 +2333,13 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,

Returns
-------
filled : same type as caller
filled : %(klass)s
"""
)

@Appender(_shared_docs['fillna'] % _shared_doc_kwargs)
def fillna(self, value=None, method=None, axis=None, inplace=False,
limit=None, downcast=None):
if isinstance(value, (list, tuple)):
raise TypeError('"value" parameter must be a scalar or dict, but '
'you passed a "{0}"'.format(type(value).__name__))
Expand Down
10 changes: 9 additions & 1 deletion pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
_shared_doc_kwargs = dict(
axes='items, major_axis, minor_axis',
klass="Panel",
axes_single_arg="{0,1,2,'items','major_axis','minor_axis'}")
axes_single_arg="{0, 1, 2, 'items', 'major_axis', 'minor_axis'}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't be changed, because the name is used in __init__ keyword?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ... indeed, this probably shouldn't be changed, i'll update

_shared_doc_kwargs['args_transpose'] = ("three positional arguments: each one"
"of\n %s" %
_shared_doc_kwargs['axes_single_arg'])
Expand Down Expand Up @@ -1161,6 +1161,14 @@ def reindex_axis(self, labels, axis=0, method=None, level=None, copy=True,
def transpose(self, *args, **kwargs):
return super(Panel, self).transpose(*args, **kwargs)

@Appender(_shared_docs['fillna'] % _shared_doc_kwargs)
def fillna(self, value=None, method=None, axis=None, inplace=False,
limit=None, downcast=None, **kwargs):
return super(Panel, self).fillna(value=value, method=method,
axis=axis, inplace=inplace,
limit=limit, downcast=downcast,
**kwargs)

def count(self, axis='major'):
"""
Return number of observations over requested axis.
Expand Down
10 changes: 9 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
_shared_doc_kwargs = dict(
axes='index',
klass='Series',
axes_single_arg="{0,'index'}",
axes_single_arg="{0, 'index'}",
inplace="""inplace : boolean, default False
If True, performs operation inplace and returns None.""",
duplicated='Series'
Expand Down Expand Up @@ -2143,6 +2143,14 @@ def rename(self, index=None, **kwargs):
def reindex(self, index=None, **kwargs):
return super(Series, self).reindex(index=index, **kwargs)

@Appender(generic._shared_docs['fillna'] % _shared_doc_kwargs)
def fillna(self, value=None, method=None, axis=None, inplace=False,
limit=None, downcast=None, **kwargs):
return super(Series, self).fillna(value=value, method=method,
axis=axis, inplace=inplace,
limit=limit, downcast=downcast,
**kwargs)

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