Description
Code Sample, a copy-pastable example if possible
Series.at
doesn't upcast to float:
In [2]: s = pd.Series([0, 1, 2], index=list('abc'))
In [3]: s.at['b'] = 2.7
In [4]: s
Out[4]:
a 0
b 2
c 2
dtype: int64
Series.iat
doesn't upcast to float:
In [5]: s = pd.Series([0, 1, 2], index=list('abc'))
In [6]: s.iat[1] = 3.1
In [7]: s
Out[7]:
a 0
b 3
c 2
dtype: int64
Series.__setitem__
doesn't upcast to float:
In [8]: s = pd.Series([0, 1, 2], index=list('abc'))
In [9]: s[1] = 5.5
In [10]: s
Out[10]:
a 0
b 5
c 2
dtype: int64
Same story for DataFrame.at
and DataFrame.iat
:
In [11]: df = pd.DataFrame({'A': [0, 1, 2]}, index=list('abc'))
In [12]: df.at['b', 'A'] = 3.14
In [13]: df
Out[13]:
A
a 0
b 3
c 2
In [14]: df.iat[1, 0] = 7.77
In [15]: df
Out[15]:
A
a 0
b 7
c 2
Note that loc
and iloc
do upcast to float for both Series
and DataFrame
:
In [16]: s = pd.Series([0, 1, 2], index=list('abc'))
In [17]: s.loc['b'] = 2.7
In [18]: s
Out[18]:
a 0.0
b 2.7
c 2.0
dtype: float64
In [19]: df = pd.DataFrame({'A': [0, 1, 2]}, index=list('abc'))
In [20]: df.iloc[0, 0] = 5.5
In [21]: df
Out[21]:
A
a 5.5
b 1.0
c 2.0
Problem description
Series.at
, Series.iat
, Series.__setitem__
, DataFrame.at
, and DataFrame.iat
do not upcast integer data to float.
Expected Output
I'd expect the values of the Series
/DataFrame
to be upcast to float in all scenarios mentioned.
Output of pd.show_versions()
INSTALLED VERSIONS
commit: e8f206d
python: 3.6.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.23.0.dev0+735.ge8f206d
pytest: 3.1.2
pip: 9.0.1
setuptools: 39.0.1
Cython: 0.25.2
numpy: 1.13.3
scipy: 1.0.0
pyarrow: 0.6.0
xarray: 0.9.6
IPython: 6.1.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: None
html5lib: 0.999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: 0.1.0
pandas_gbq: None
pandas_datareader: None