-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: .at/.iat and Series.__setitem__ do not upcast int to float #20643
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
Comments
Hmm...that does seem a little odd. We should have consistency. |
i would like to take this. |
Go for it! |
Note that this also affects what happens when you try to set a value to >>> s = pd.Series([0, 1, 2], index=list('abc'))
>>> s.iat[0] = 5
>>> s
a 5
b 1
c 2
dtype: int64 Setting a value to >>> s.iat[0] = None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MYINSTALLDIR/site-packages/pandas/core/indexing.py", line 1886, in __setitem__
self.obj._set_value(*key, takeable=self._takeable)
File "MYINSTALLDIR/site-packages/pandas/core/series.py", line 965, in _set_value
self._values[label] = value
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' Setitng a value to >>> s.iloc[0] = None
>>> s
a NaN
b 1.0
c 2.0
dtype: float64 |
This looks like it is working now, could use test |
Code Sample, a copy-pastable example if possible
Series.at
doesn't upcast to float:Series.iat
doesn't upcast to float:Series.__setitem__
doesn't upcast to float:Same story for
DataFrame.at
andDataFrame.iat
:Note that
loc
andiloc
do upcast to float for bothSeries
andDataFrame
:Problem description
Series.at
,Series.iat
,Series.__setitem__
,DataFrame.at
, andDataFrame.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
The text was updated successfully, but these errors were encountered: