#dataframe['c'] = pandas.Categorical.from_array(dataframe.col3).codes

Read more of this post