@@ -1623,8 +1623,12 @@ def fillna(self, value=None, method=None, limit=None):
1623
1623
Method to use for filling holes in reindexed Series
1624
1624
pad / ffill: propagate last valid observation forward to next valid
1625
1625
backfill / bfill: use NEXT valid observation to fill gap
1626
- value : scalar
1627
- Value to use to fill holes (e.g. 0)
1626
+ value : scalar, dict, Series
1627
+ If a scalar value is passed it is used to fill all missing values.
1628
+ Alternatively, a Series or dict can be used to fill in different
1629
+ values for each index. The value should not be a list. The
1630
+ value(s) passed should either be in the categories or should be
1631
+ NaN.
1628
1632
limit : int, default None
1629
1633
(Not implemented yet for Categorical!)
1630
1634
If method is specified, this is the maximum number of consecutive
@@ -1665,6 +1669,8 @@ def fillna(self, value=None, method=None, limit=None):
1665
1669
1666
1670
else :
1667
1671
1672
+ # If value is a dict or a Series (a dict value has already
1673
+ # been converted to a Series)
1668
1674
if isinstance (value , ABCSeries ):
1669
1675
if not value [~ value .isin (self .categories )].isna ().all ():
1670
1676
raise ValueError ("fill value must be in categories" )
@@ -1673,7 +1679,7 @@ def fillna(self, value=None, method=None, limit=None):
1673
1679
indexer = np .where (values_codes != - 1 )
1674
1680
values [indexer ] = values_codes [values_codes != - 1 ]
1675
1681
1676
- # Scalar value
1682
+ # If value is not a dict or Series it should be a scalar
1677
1683
else :
1678
1684
if not isna (value ) and value not in self .categories :
1679
1685
raise ValueError ("fill value must be in categories" )
0 commit comments