BUG: changing series dtype inplace #4463

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

Comments

Projects
None yet
2 participants
Contributor

jreback 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
Contributor

jreback commented Aug 5, 2013

will be resolved in #3482

Contributor

hayd commented Aug 7, 2013

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

Contributor

jreback commented Aug 7, 2013

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

Contributor

jreback commented Aug 7, 2013

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

Contributor

hayd 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).

Contributor

hayd commented Aug 7, 2013

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

Contributor

jreback commented Aug 7, 2013

hah!

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

Contributor

hayd commented Aug 7, 2013

@jreback er I meant #4204 lol!

Contributor

jreback 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

Contributor

hayd 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

Contributor

jreback commented Aug 16, 2013

closed by #3482

jreback closed this Aug 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment