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

Closed
hayd opened this issue Jul 11, 2013 · 2 comments
Closed

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

hayd opened this issue Jul 11, 2013 · 2 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@hayd
Copy link
Contributor

hayd 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
Out[3]:
                     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)
     86
     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 np.prod(values.shape):
    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
@jreback
Copy link
Contributor

jreback commented Jul 11, 2013

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

@jreback
Copy link
Contributor

jreback commented Aug 16, 2013

closed by #3482

@jreback jreback closed this as completed Aug 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

2 participants