Skip to content
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

BUG: loc setting NaN in an int column should upcast #4204

hayd opened this issue Jul 11, 2013 · 2 comments


Copy link

commented Jul 11, 2013

I think upcasting to float should occur here.

For example:

In [1]: df = pd.DataFrame([[0, 0]])

In [2]: df.loc[0] = np.nan

In [3]: df
                     0                    1
0 -9223372036854775808 -9223372036854775808

Sometimes this is caught:

In [11]: df = pd.DataFrame([[0]])

In [12]: df.loc[0] = np.nan
ValueError                                Traceback (most recent call last)
<ipython-input-12-92653b6a9ef8> in <module>()
----> 1 df.loc[0] = np.nan

/Users/234BroadWalk/pandas/core/indexing.pyc in __setitem__(self, key, value)
     87         self._setitem_with_indexer(indexer, value)
---> 88
     89     def _has_valid_tuple(self, key):
     90         pass

/Users/234BroadWalk/pandas/core/indexing.pyc in _setitem_with_indexer(self, indexer, value)
    183             if
    184                 values[indexer] = value
--> 185
    186     def _align_series(self, indexer, ser):
    187         # indexer to assign Series can be tuple or scalar

ValueError: cannot convert float NaN to integer

This comment has been minimized.

Copy link

commented Jul 11, 2013

this works in a mixed-frame, but the path for single dtype frame is different, sigh :(


This comment has been minimized.

Copy link

commented Aug 16, 2013

closed by #3482

@jreback jreback closed this Aug 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.