Skip to content

Categorical.fillna doesn't validate consistent kwargs #19682

Closed
@TomAugspurger

Description

@TomAugspurger
In [3]: pd.Categorical(['a', 'b']).fillna(value='a', method='ffill')
Out[3]:
[a, b]
Categories (2, object): [a, b]

In [4]: pd.Series(pd.Categorical(['a', 'b'])).fillna(value='a', method='ffill')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-141070886f71> in <module>()
----> 1 pd.Series(pd.Categorical(['a', 'b'])).fillna(value='a', method='ffill')

~/sandbox/pandas-ip/pandas/pandas/core/series.py in fillna(self, value, method, axis, inplace, limit, downcast, **kwargs)
   2659                                           axis=axis, inplace=inplace,
   2660                                           limit=limit, downcast=downcast,
-> 2661                                           **kwargs)
   2662
   2663     @Appender(generic._shared_docs['replace'] % _shared_doc_kwargs)

~/sandbox/pandas-ip/pandas/pandas/core/generic.py in fillna(self, value, method, axis, inplace, limit, downcast)
   4745         else:
   4746             if method is not None:
-> 4747                 raise ValueError('cannot specify both a fill method and value')
   4748
   4749             if len(self._get_axis(axis)) == 0:

ValueError: cannot specify both a fill method and value

Both of these should raise. PR coming shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignCategoricalCategorical Data TypeMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions