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 :: the most effective search algorithm in python 
Python :: threading lock example 
Python :: axes in array 
Python :: generating cross tables after clustering 
Python :: kite order syntax 
Python :: if you have a list and the user input one of the keys then output its value 
Python :: Normalize basic list data 
Python :: complete pipeline sample 
Python :: contigent def 
Python :: find difference between two triangular numbers python 
Python :: website screenshot python compress image 
Python :: python concurrent.futures.ProcessPoolExecutor multiple arguments 
Python :: wn.synset vs wn.synsets in nltk 
Python :: vectorized function 
Python :: if variable does not contain py 
Python :: how to access github folder in python code using github https link 
Python :: replace python enter number of characters 
Python :: custom_settings in scrpay 
Python :: python print top 5 results of array 
Python :: create canvas for signature flutter 
Python :: What is the purpose of open ( ) and close ( ) in os 
Python :: a problem of predicting whether a student succeed or not based of his GPA and GRE. for logistic regression 
Python :: python script superuser 
Python :: python exit while loop 
Python :: get last item in array python 
Python :: scrapy itemloader example 
Python :: visualizzare csv in pycharm pandas read_csv 
Python :: pyfcm image 
Python :: python write request must be str not bytes 
Python :: python library automatic sort 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =