Skip to content

fillna/fill_value fails when filling with a list #3526

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
lodagro opened this issue May 3, 2013 · 1 comment
Closed

fillna/fill_value fails when filling with a list #3526

lodagro opened this issue May 3, 2013 · 1 comment

Comments

@lodagro
Copy link
Contributor

lodagro commented May 3, 2013

In [48]: s = pd.Series([np.NaN, 'hello world'])

In [49]: s
Out[49]: 
0            NaN
1    hello world
dtype: object

In [50]: s.fillna([])
Out[50]: 
0            NaN
1    hello world
dtype: object

In [51]: s.fillna(['not empty'])
Out[51]: 
0      not empty
1    hello world
dtype: object

Had a quick peak in the code and it looks like a numpy issue (1.6.2)

In [52]: a = np.array([np.NaN, 'hello world'])

In [53]: m = np.array([True, False])

In [54]: a[m] = []

In [55]: a
Out[55]: 
array(['nan', 'hello world'], 
      dtype='|S11')

In [56]: a[m] = ['not empty']

In [57]: a
Out[57]: 
array(['not empty', 'hello world'], 
      dtype='|S11')

similar issue when using operators supporting fill_value

In [58]: s1 = pd.Series([np.NaN, [1,2], [10, 20]])

In [59]: s2 = pd.Series([[3,4], np.NaN, [30, 40]])

In [60]: s1.add(s2, fill_value=[])

...
TypeError: unsupported operand type(s) for +: 'float' and 'list'

Did not try for DataFrame, but i suppose this will be the same.

@lodagro
Copy link
Contributor Author

lodagro commented May 6, 2013

close, duplicate of #3435

@lodagro lodagro closed this as completed May 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant