If look at Rank column
This is correct as you see the same on website.
Change line 10 to this:
If need
df2['Rank']
,see that not all countries get a Rank number but -
.This is correct as you see the same on website.
Change line 10 to this:
df0 = pd.read_html(str(sov_tables), na_values='ā')Do
df2.dtypes
Output:Rank float64
Country name object
Population int64
Date object
% of world population object
dtype: object
No int
because of NaN values.If need
int
most drop NaN with dropna()
.df2['Rank'] = df2['Rank'].astype('int')For Date do this.
df2['Date'] = pd.to_datetime(df2['Date'])
Output:Rank int32
Country name object
Population int64
Date datetime64[ns]
% of world population object
One to go.