A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/44965 below:

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

Skip to content Navigation Menu

Saved searches Use saved searches to filter your results more quickly

Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert Additional navigation options

BUG: Apply pd.get_dummies() on string type columns of pandas dataframe do nothing? #44965

Description 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

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4