Closed
Description
xref #10264
converts int -> floats for the entire block.
In [1]: x = pd.DataFrame(data=np.zeros((5,5),dtype=np.int),columns=['a','b','c','d','e'], index=['one','two','three','four','five'])
In [3]: x.loc['three','e'] = 3.1
In [4]: x
Out[4]:
a b c d e
one 0 0 0 0 0.0
two 0 0 0 0 0.0
three 0 0 0 0 3.1
four 0 0 0 0 0.0
five 0 0 0 0 0.0
In [5]: x.dtypes
Out[5]:
a float64
b float64
c float64
d float64
e float64
dtype: object
ok for other kinds of assignments
In [6]: x = pd.DataFrame(data=np.zeros((5,5),dtype=np.int),columns=['a','b','c','d','e'], index=['one','two','three','four','five'])
[8]: x.loc['three','e'] = 'foo'
In [9]: x
Out[9]:
a b c d e
one 0 0 0 0 0
two 0 0 0 0 0
three 0 0 0 0 foo
four 0 0 0 0 0
five 0 0 0 0 0
In [10]: x.dtypes
Out[10]:
a int64
b int64
c int64
d int64
e object
dtype: object