Skip to content

Commit e3c7862

Browse files
Merge pull request #10009 from mortada/fillna_doc_fix
DOC: improve fillna() doc for limit keyword (fixes #10002)
2 parents a6ae1af + 1ee3d82 commit e3c7862

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

pandas/core/categorical.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,13 @@ def fillna(self, value=None, method=None, limit=None):
11811181
value : scalar
11821182
Value to use to fill holes (e.g. 0)
11831183
limit : int, default None
1184-
Maximum size gap to forward or backward fill (not implemented yet!)
1184+
(Not implemented yet for Categorical!)
1185+
If method is specified, this is the maximum number of consecutive
1186+
NaN values to forward/backward fill. In other words, if there is
1187+
a gap with more than this number of consecutive NaNs, it will only
1188+
be partially filled. If method is not specified, this is the
1189+
maximum number of entries along the entire axis where NaNs will be
1190+
filled.
11851191
11861192
Returns
11871193
-------

pandas/core/generic.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,12 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
23192319
other views on this object, (e.g. a no-copy slice for a column in a
23202320
DataFrame).
23212321
limit : int, default None
2322-
Maximum size gap to forward or backward fill
2322+
If method is specified, this is the maximum number of consecutive
2323+
NaN values to forward/backward fill. In other words, if there is
2324+
a gap with more than this number of consecutive NaNs, it will only
2325+
be partially filled. If method is not specified, this is the
2326+
maximum number of entries along the entire axis where NaNs will be
2327+
filled.
23232328
downcast : dict, default is None
23242329
a dict of item->dtype of what to downcast if possible,
23252330
or the string 'infer' which will try to downcast to an appropriate

pandas/core/internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def fillna(self, value, limit=None, inplace=False, downcast=None):
296296
if self.ndim > 2:
297297
raise NotImplementedError("number of dimensions for 'fillna' "
298298
"is currently limited to 2")
299-
mask[mask.cumsum(self.ndim-1)>limit]=False
299+
mask[mask.cumsum(self.ndim-1) > limit] = False
300300

301301
value = self._try_fill(value)
302302
blocks = self.putmask(mask, value, inplace=inplace)

0 commit comments

Comments
 (0)