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: changing series dtype inplace #4463

Closed
jreback opened this issue Aug 5, 2013 · 11 comments

Comments

@jreback
Copy link
Contributor

commented Aug 5, 2013

All of the following current fail because of in-place dtype conversions

In [2]: s = Series([1,2,3])
In [3]: s.iloc[0] = np.nan
ValueError: cannot convert float NaN to integer

In [4]: s.loc[0] = np.nan
ValueError: cannot convert float NaN to integer

In [5]: s[0] = np.nan
TypeError: 'int' object is not iterable
@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2013

will be resolved in #3482

@hayd

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2013

dupish: #4204 (but not quite). cough not 4463 cough!

@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2013

@hayd you did a cycle reference! (its the same issue)

@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2013

can't garbage collect it now......:)

@hayd

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2013

Think it makes sense to mention here the bools thing here too from #4170.

In [13]: b = pd.Series([False])

In [14]: b.loc[0] = pd.np.nan

In [15]: b
Out[15]:
0    True
dtype: bool

not sure if should upcast to object (or float).

@hayd

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2013

@jreback pfft, only the second half is the same :)

@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2013

hah!

yes....basically the same issue (which is fixed in 3482, but will add this test as well)..thanks

@hayd

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2013

@jreback er I meant #4204 lol!

@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2013

thanks....actually did have a tniy bug (because numpy sucks!), here's a doozy:

In [14]: s
Out[14]: array([False], dtype=bool)

In [15]: s[0] = np.nan

In [16]: s
Out[16]: array([ True], dtype=bool)

Here's some examples of it working (2nd one is interesting)

In [17]: s = Series([False])

In [18]: s[0] = np.nan

In [19]: s
Out[19]: 
0   NaN
dtype: float64

In [4]: s = Series([False,True])

In [5]: s.loc[0] = np.nan

In [6]: s
Out[6]: 
0   NaN
1     1
dtype: float64

@hayd

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2013

Ha! ...good ol' numpy.

I think upcasting to float is the right call at the moment (although I am a fan of object dtype ;) ), like wes mentioned at some point we should think of a better NaN solution... :s

@jreback

This comment has been minimized.

Copy link
Contributor Author

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
Projects
None yet
2 participants
You can’t perform that action at this time.