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

Categorical.fillna doesn't accept tuples #19788

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

Comments

Projects
None yet
2 participants
@TomAugspurger
Contributor

TomAugspurger commented Feb 20, 2018

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 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 added a commit that referenced this issue May 28, 2018

jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this issue Jun 8, 2018

jorisvandenbossche added a commit that referenced this issue Jun 9, 2018

BUG: Categorical.fillna with iterables (#21215)
Closes #19788
Closes #21097
(cherry picked from commit 36c1f6b)

david-liu-brattle-1 added 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