Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Changing the data type to category

# Specify the logical order of the weather ratings
cats = pd.CategoricalDtype(['good', 'bad', 'worse'], ordered=True)

# Change the data type of 'rating' to category
df['column'] = df.column.astype(cats)
Source by campus.datacamp.com #
 
PREVIOUS NEXT
Tagged: #Changing #data #type #category
ADD COMMENT
Topic
Name
4+6 =