Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

convert to category data type

df = df['col_name'].astype('category')
Comment

PREVIOUS NEXT
Code Example
Python :: feature importance plot using lasso regression 
Python :: check if object exists python 
Python :: how to plot a single cluster 
Python :: py var to the power of 
Python :: how to append dict to dict in python 
Python :: pyspark parquet to dataframe 
Python :: Example code of while loop in python 
Python :: how to import a variable from another python file 
Python :: how to fit the whole text beside checkbox in ipywidgets 
Python :: import in python 
Python :: function for permutation sampling 
Python :: form field required in django views 
Python :: how to slice a set in python 
Python :: unpacking in python 
Python :: Prints all integers of a list 
Python :: Forbidden (CSRF token missing or incorrect.): /extension/stripe-pay/ WARNING 2021-06-01 13:45:22,532 log 408 140165573588736 Forbidden (CSRF token missing or incorrect.): /extension/stripe-pay/ 
Python :: kivy stuck in fullscreen in jupyter notebook macbook 
Python :: activate python venv in windows 
Python :: recorrer lista desde el final python 
Python :: split custom pytorch dataset 
Python :: dependency inversion 
Python :: seaborn python 
Python :: check if input is pandas dataframe 
Python :: python iterate over tuple of lists 
Python :: keras functional api embedding layer 
Python :: fonts in python 
Python :: python int to scientific string 
Python :: add button to python gui file 
Python :: programmer tool 
Python :: how to import ui file in pyside 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =