We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
df = pd.DataFrame([list('abc')]) print(df) df.loc[:, 'col1'] = int(5) df['col2'] = int(5) df = df.assign(col3=int(5)) print(df.dtypes) print(df) 0 1 2 0 a b c 0 object 1 object 2 object col1 float64 col2 int64 col3 int64 dtype: object 0 1 2 col1 col2 col3 0 a b c 5.0 5 5
The fact that df.loc[:,'col1] = int(5) yields a new column with dtype float64 seems strange.
df.loc[:,'col1] = int(5)
float64
All three methods should yield a new column with dtype int64
int64
pd.show_versions()
pandas: 0.23.4 pytest: 3.8.2 pip: 18.1 setuptools: 40.4.3 Cython: None numpy: 1.15.0 scipy: 1.1.0 pyarrow: None xarray: None IPython: 5.8.0 sphinx: None patsy: None dateutil: 2.7.3 pytz: 2018.5 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: 2.2.3 openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: None sqlalchemy: None pymysql: None psycopg2: 2.7.5 (dt dec pq3 ext lo64) jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
The text was updated successfully, but these errors were encountered:
Thanks for the report - investigation and PRs are certainly welcome!
Sorry, something went wrong.
i would like to give a try...
This looks correct on master. Could use a test
In [22]: df = pd.DataFrame([list('abc')]) ...: print(df) ...: ...: df.loc[:, 'col1'] = int(5) ...: df['col2'] = int(5) ...: df = df.assign(col3=int(5)) ...: ...: print(df.dtypes) ...: print(df) 0 1 2 0 a b c 0 object 1 object 2 object col1 int64 col2 int64 col3 int64 dtype: object 0 1 2 col1 col2 col3 0 a b c 5 5 5
Successfully merging a pull request may close this issue.
Problem description
The fact that
df.loc[:,'col1] = int(5)
yields a new column with dtypefloat64
seems strange.Expected Output
All three methods should yield a new column with dtype
int64
Output of
pd.show_versions()
pandas: 0.23.4
pytest: 3.8.2
pip: 18.1
setuptools: 40.4.3
Cython: None
numpy: 1.15.0
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 5.8.0
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: 2.7.5 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: