-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Closed
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolatenp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Description
pd.get_dummies(pd.DataFrame({"id":[1,2,3]}), columns=["id"], dummy_na=True)
will produce
id_1.0 | id_2.0 | id_3.0 | id_nan | |
---|---|---|---|---|
0 | 1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 | 0 |
2 | 0 | 0 | 1 | 0 |
Which creates different column names from pd.get_dummies(pd.DataFrame({"id":[1,2,3]}), columns=["id"])
id_1 | id_2 | id_3 | |
---|---|---|---|
0 | 1 | 0 | 0 |
1 | 0 | 1 | 0 |
2 | 0 | 0 | 1 |
It looks that this line
pandas/pandas/core/reshape/reshape.py
Line 909 in 6c0c277
levels = np.append(levels, np.nan) |
converts the int array into float array because of np.nan
.
Metadata
Metadata
Assignees
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolatenp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate