I want to have ha elegant function to cast all object columns in a pandas data frame to categories
df[x] = df[x].astype("category")
performs the type cast
df.select_dtypes(include=['object'])
would sub-select all categories columns. However this results in a loss of the other columns / a manual merge is required. Is there a solution which "just works in place" or does not require a manual cast?
edit
I am looking for something similar as http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.convert_objects.html for a conversion to categorical data