Skip to content

Categorical.fillna doesn't accept tuples #19788

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

Closed
TomAugspurger opened this issue Feb 20, 2018 · 0 comments
Closed

Categorical.fillna doesn't accept tuples #19788

TomAugspurger opened this issue Feb 20, 2018 · 0 comments
Labels
Categorical Categorical Data Type Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@TomAugspurger
Copy link
Contributor

This should maybe work.

In [1]: import pandas as pd

In [2]: pd.Categorical([(1, 2), None]).fillna((1, 2))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-73c5b4ab00c2> in <module>()
----> 1 pd.Categorical([(1, 2), None]).fillna((1, 2))

~/sandbox/pandas-ip/pandas/pandas/util/_decorators.py in wrapper(*args, **kwargs)
    136                 else:
    137                     kwargs[new_arg_name] = new_arg_value
--> 138             return func(*args, **kwargs)
    139         return wrapper
    140     return _deprecate_kwarg

~/sandbox/pandas-ip/pandas/pandas/core/arrays/categorical.py in fillna(self, value, method, limit)
   1664                 raise TypeError('"value" parameter must be a scalar, dict '
   1665                                 'or Series, but you passed a '
-> 1666                                 '"{0}"'.format(type(value).__name__))
   1667
   1668         return self._constructor(values, categories=self.categories,

TypeError: "value" parameter must be a scalar, dict or Series, but you passed a "tuple"

xref #19684

This could be a can of worms if we want to accept Series(categorical).fillna(tuple), since it's not allowed there. Would accept incremental improvements here of course.

@TomAugspurger TomAugspurger added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Categorical Categorical Data Type Difficulty Intermediate labels Feb 20, 2018
@TomAugspurger TomAugspurger added this to the Next Major Release milestone Feb 20, 2018
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue May 26, 2018
@jreback jreback modified the milestones: Next Major Release, 0.23.1 May 28, 2018
jreback pushed a commit that referenced this issue May 28, 2018
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this issue Jun 8, 2018
jorisvandenbossche pushed a commit that referenced this issue Jun 9, 2018
Closes #19788
Closes #21097
(cherry picked from commit 36c1f6b)
david-liu-brattle-1 pushed a commit to david-liu-brattle-1/pandas that referenced this issue Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

No branches or pull requests

2 participants