Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Add New Column to Pandas from Dictionary

pop_dict = {'Europe': 24504794.99, 
'Oceania': 8874672.33, 
'Africa': 77038721.97, 
'Asia': 9916003.14, 
'Americas': 17169764.73}

gapminder_df['pop']= gapminder_df['continent'].map(pop_dict)
Source by cmdlinetips.com #
 
PREVIOUS NEXT
Tagged: #Add #New #Column #Pandas #Dictionary
ADD COMMENT
Topic
Name
4+3 =