-
Notifications
You must be signed in to change notification settings - Fork 884
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
[BUG] Adding a string column to an empty dataframe changes all column dtypes to float64 #1172
Comments
@beckernick I was looking at this issue and realised that pandas also does the same as cudf. here is minimal repro: In [1]: import pandas as pd
...: cols = ['a', 'b', 'c']
...: df = pd.DataFrame(columns=cols, dtype='int')
...: df['a']=[1,2,]
...: df.dtypes
Out[1]:
a int64
b float64
c float64
dtype: object I just want to know that Are we gonna differ from pandas behaviour in this scenario? |
This is interesting @AK-ayush. cc @kkraus14 for visibility. We appear to be consistent with pandas 0.24 for numeric types, but not string type columns (examples below). From a quick glance it seems like this is due to the handling of I'm inclined to maintain consistency with Pandas. I think the key consistency bug is that
Pandas object behavior going to object
Pandas int behavior going to numeric
Pandas object behavior going to integer
Our behavior going from object to int
We also don't yet maintain object type consistency when using
|
I have created PR for stating the issue of adding column to str dataframe but I was trying to solve the |
[REVIEW]Fix dtypes issue #1172 while adding a col to empty object dataframe
This is resolved by #1233 . Closing. |
Describe the bug
Adding a column to an empty dataframe changes all column dtypes to float64.
Steps/Code to reproduce bug
Expected behavior
I expect empty dataframe columns with specific types to remain the same when the first column is added of a different type.
Environment details (please complete the following information):
The text was updated successfully, but these errors were encountered: