I’m having trouble understanding this practice problem:
Loading and Exploring Data Practice Problems
20. World Population Percentages
Screen Link:
My Code:
countries['Pop Percent'] = (countries['Population'] / countries['Population'].sum()) * 100
What I expected to happen:
I made a copy of the countries DataFrame (countries1).
I expected to get the same result as this:
countries1['Pop Percent'] = 100 * countries1['Population'] / countries1['Population'].sum()
What actually happened:
When I checked using:
countries.equals(countries1)
It returned False when I expected True.
I checked a few rows and the Pop Percent values matched. So why are they different?
Thank you for your help in advance.