Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Series
What DataFrames are
DataFrame columns
15. Adding a new column
DataFrame rows
Filtering rows and columns
Filtering data frames
Sorting rows
Summary

Instruction

Well done! Often you want to combine data from multiple columns to create a new column. To do this in Python, use the bracket operator again. Take a look:

hospitals['Full City'] = hospitals['City'] + ', ' + hospitals['State']

The code above will create a new column named Full City. It will take the city name and add its state after a comma. This time, we used single brackets.

Exercise

Add a new column to eu_states named GDP Per Capita, calculated as GDP divided by Population. Because GDP was expressed in millions of dollars, multiply the result by 1 000 000 to obtain the full amount in GDP Per Capita.

Stuck? Here's a hint!

Begin with:

eu_states['GDP Per Capita'] =

Then divide the GDP column by the Population column, and finally multiply the result by 1 000 000.