Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas change multiple column types

#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')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #change #multiple #column #types
ADD COMMENT
Topic
Name
4+5 =