Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas convert multiple columns to categorical

#Two ways to do this
df[['parks', 'playgrounds', 'sports']].apply(lambda x: x.astype('category'))

cols = ['parks', 'playgrounds', 'sports', 'roading']:
public[cols] = public[cols].astype('category')
Comment

PREVIOUS NEXT
Code Example
Python :: split a given number in python 
Python :: python folder exists 
Python :: change default option optionmenu tkinter 
Python :: python convert list of strings to list of integers 
Python :: how to delete a specific line in a file 
Python :: python subprocess with environment variables 
Python :: python procedured 
Python :: pandas apply pass in arguments 
Python :: how to check if email exists in python 
Python :: take array of string in python 
Python :: colored text in py 
Python :: sklearn train_test_split 
Python :: pandas read csv 
Python :: print ocaml 
Python :: ip regex python 
Python :: how to merge two dataframes 
Python :: python datetime weekday 
Python :: glob list all files in directory 
Python :: python fill string with 0 left 
Python :: pandas dataframe from tsv 
Python :: how to check python version on terminal 
Python :: python regex get string before character 
Python :: ursina python 
Python :: make binary tree in python 
Python :: python try catch 
Python :: serial clear buffer python 
Python :: how to search a file in windows 10 using python 
Python :: how to use timeit in python 3 
Python :: append one row to pandas dataframe 
Python :: get pixel color pygame 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =