BUG: Apply pd.get_dummies() on string type columns of pandas dataframe do nothing? · Issue #44965 · pandas-dev/pandas (original) (raw)

Pandas version checks

Reproducible Example

I have the following dataframe:

df = pd.DataFrame({'a': [6.6, -5.2, 2.1, 3.3, 1.1],
              'b': ['a', 'a', 'c', 'b', 'a'],
              'c': ['kfr', 'kfr', 'lu', 'ku', 'lu'],
              'd': ['t', 's', 's', 't', 'a']})

All the dtypes (columns b, c, d) are of type string.

If I call df = df.convert_dtypes(), and then call pd.get_dummies(), nothing happens:

df = pd.DataFrame({'a': [6.6, -5.2, 2.1, 3.3, 1.1],
              'b': ['a', 'a', 'c', 'b', 'a'],
              'c': ['kfr', 'kfr', 'lu', 'ku', 'lu'],
              'd': ['t', 's', 's', 't', 'a']})
df = df.convert_dtypes()
pd.get_dummies(df)

But if I will change the df.convert_dtypes() to df.convert_dtypes(convert_string=False) it will work as expected.
Why is this happening? Is it a bug?

Expected Behavior

pandas pd.get_dummies() should work on strings columns dtype also.

Installed Versions

1.3.5