Skip to content

Commit ec38d71

Browse files
committed
DOC: use _shared_docs for fillna methods
1 parent 7eb5668 commit ec38d71

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

pandas/core/frame.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# Docstring templates
6767

6868
_shared_doc_kwargs = dict(axes='index, columns', klass='DataFrame',
69-
axes_single_arg="{0,1,'index','columns'}")
69+
axes_single_arg="{0, 1, 'index', 'columns'}")
7070

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

2518+
@Appender(_shared_docs['fillna'] % _shared_doc_kwargs)
2519+
def fillna(self, value=None, method=None, axis=None, inplace=False,
2520+
limit=None, downcast=None, **kwargs):
2521+
return super(DataFrame, self).fillna(value=value, method=method,
2522+
axis=axis, inplace=inplace,
2523+
limit=limit, downcast=downcast,
2524+
**kwargs)
2525+
25182526
def set_index(self, keys, drop=True, append=False, inplace=False,
25192527
verify_integrity=False):
25202528
"""

pandas/core/generic.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,8 +2295,7 @@ def convert_objects(self, convert_dates=True, convert_numeric=False,
22952295
#----------------------------------------------------------------------
22962296
# Filling NA's
22972297

2298-
def fillna(self, value=None, method=None, axis=None, inplace=False,
2299-
limit=None, downcast=None):
2298+
_shared_docs['fillna'] = (
23002299
"""
23012300
Fill NA/NaN values using the specified method
23022301
@@ -2311,9 +2310,7 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
23112310
values specifying which value to use for each index (for a Series) or
23122311
column (for a DataFrame). (values not in the dict/Series/DataFrame will not be
23132312
filled). This value cannot be a list.
2314-
axis : {0, 1}, default 0
2315-
* 0: fill column-by-column
2316-
* 1: fill row-by-row
2313+
axis : %(axes_single_arg)s
23172314
inplace : boolean, default False
23182315
If True, fill in place. Note: this will modify any
23192316
other views on this object, (e.g. a no-copy slice for a column in a
@@ -2336,8 +2333,13 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
23362333
23372334
Returns
23382335
-------
2339-
filled : same type as caller
2336+
filled : %(klass)s
23402337
"""
2338+
)
2339+
2340+
@Appender(_shared_docs['fillna'] % _shared_doc_kwargs)
2341+
def fillna(self, value=None, method=None, axis=None, inplace=False,
2342+
limit=None, downcast=None):
23412343
if isinstance(value, (list, tuple)):
23422344
raise TypeError('"value" parameter must be a scalar or dict, but '
23432345
'you passed a "{0}"'.format(type(value).__name__))

pandas/core/panel.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
_shared_doc_kwargs = dict(
3535
axes='items, major_axis, minor_axis',
3636
klass="Panel",
37-
axes_single_arg="{0,1,2,'items','major_axis','minor_axis'}")
37+
axes_single_arg="{0, 1, 2, 'items', 'major_axis', 'minor_axis'}")
3838
_shared_doc_kwargs['args_transpose'] = ("three positional arguments: each one"
3939
"of\n %s" %
4040
_shared_doc_kwargs['axes_single_arg'])
@@ -1161,6 +1161,14 @@ def reindex_axis(self, labels, axis=0, method=None, level=None, copy=True,
11611161
def transpose(self, *args, **kwargs):
11621162
return super(Panel, self).transpose(*args, **kwargs)
11631163

1164+
@Appender(_shared_docs['fillna'] % _shared_doc_kwargs)
1165+
def fillna(self, value=None, method=None, axis=None, inplace=False,
1166+
limit=None, downcast=None, **kwargs):
1167+
return super(Panel, self).fillna(value=value, method=method,
1168+
axis=axis, inplace=inplace,
1169+
limit=limit, downcast=downcast,
1170+
**kwargs)
1171+
11641172
def count(self, axis='major'):
11651173
"""
11661174
Return number of observations over requested axis.

pandas/core/series.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
_shared_doc_kwargs = dict(
6060
axes='index',
6161
klass='Series',
62-
axes_single_arg="{0,'index'}",
62+
axes_single_arg="{0, 'index'}",
6363
inplace="""inplace : boolean, default False
6464
If True, performs operation inplace and returns None.""",
6565
duplicated='Series'
@@ -2143,6 +2143,14 @@ def rename(self, index=None, **kwargs):
21432143
def reindex(self, index=None, **kwargs):
21442144
return super(Series, self).reindex(index=index, **kwargs)
21452145

2146+
@Appender(generic._shared_docs['fillna'] % _shared_doc_kwargs)
2147+
def fillna(self, value=None, method=None, axis=None, inplace=False,
2148+
limit=None, downcast=None, **kwargs):
2149+
return super(Series, self).fillna(value=value, method=method,
2150+
axis=axis, inplace=inplace,
2151+
limit=limit, downcast=downcast,
2152+
**kwargs)
2153+
21462154
def reindex_axis(self, labels, axis=0, **kwargs):
21472155
""" for compatibility with higher dims """
21482156
if axis != 0:

0 commit comments

Comments
 (0)