# get all categorical columns in the dataframe
catCols = [col for col in df1.columns if df1[col].dtype=="O"]
from sklearn.preprocessing import LabelEncoder
lb_make = LabelEncoder()
for item in catCols:
df1[item] = lb_make.fit_transform(df1[item])
#this will label as one hot vectors (origin is split into 3 columns - USA, Europe, Japan and any one place will be 1 while the others are 0)
dataset['Origin'] = dataset['Origin'].map({1: 'USA', 2: 'Europe', 3: 'Japan'})
how to convert contionous data into categorical data in python
pd.cut(df.Age,bins=[0,2,17,65,99],labels=['Toddler/Baby','Child','Adult','Elderly'])
# where bins is cut off points of bins for the continuous data
# and key things here is that no. of labels is always less than 1