DataFrames not equal for Loading and Exploring Data Practice Problems #20

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:


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.

Kindly run this code snippet:

countries[['Pop Percent']] == countries1[['Pop Percent']]

countries[['Pop Percent']].iloc[222,-1],countries1[['Pop Percent']].iloc[222,-1]

(0.037714212108236715, 0.03771421210823672)

There is a little difference at the end with the way Python executes the code.

You can round the figures to be sure to get the desired output.

countries1 = countries.copy()

countries['Pop Percent'] = round((countries['Population'] / countries['Population'].sum()) * 100,5)

countries1['Pop Percent'] = round(100 * countries1['Population'] / countries1['Population'].sum(), 5)
countries[['Pop Percent']].equals(countries1[['Pop Percent']])