<jupyter_start><jupyter_text>World Population Exploratory Data This project is meant to visualize population data using matplotlib and seaborn<jupyter_code># dependencies

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.style as style
import seaborn as sns
%matplotlib inline
data = pd.read_csv('popbycountry1980_2010.csv')
data.head(10)
data.info()
data.columns
cleaned_data = data[(
    data['Nation'] != 'World') 
    & (data['Nation'] != 'Asia & Oceania') 
    & (data['Nation'] != 'Europe')
    & (data['Nation'] != 'Africa')
    & (data['Nation'] != 'North America')
    & (data['Nation'] != 'Central & South America')
    & (data['Nation'] != 'Former U.S.S.R.')
    & (data['Nation'] != 'Eurasia')
    & (data['Nation'] != 'Middle East')
] 


pop_1980 = cleaned_data[['Nation', 'Year1980']]
pop_1980['Year1980'] = pop_1980['Year1980'].str.replace('--', '0').astype(float)
top_pop_1980 = pop_1980.sort_values(by=['Year1980'], ascending=False)[:10]
top_pop_1980

style.use('seaborn-notebook')
top_pop_1980.plot.bar(x='Nation', y='Year1980')
plt.title('Top 10 Country Population in 1980')
plt.legend('')
plt.xlabel('')
plt.ylabel('Population In Millions')
plt.show()
pop_2010 = cleaned_data[['Nation', 'Year2010']]
pop_2010['Year2010'].value_counts()
pop_2010['Year2010'] = pop_2010['Year2010'].str.replace('--', '0').astype(float)
top_pop_2010 = pop_2010.sort_values(by=['Year2010'], ascending=False)
top_pop_2010 = top_pop_2010[:10]
top_pop_2010
style.use('seaborn-notebook')
top_pop_2010.plot.bar(x='Nation', y='Year2010')
plt.title('Top 10 Population in 2010')
plt.legend('')
plt.ylabel('Population in Millions')
plt.xlabel('')
plt.show()
combined = pd.concat([top_pop_1980, top_pop_2010], axis=1)
combined = combined.reset_index(drop=True)
combined = combined.dropna()
combined['AvgGrowthRate'] = (combined['Year2010'] - combined['Year1980'])/(2010-1980)
combined.sort_values(by='AvgGrowthRate', ascending=False)

combined['Nations'] = combined.iloc[:, :1]
combined = combined.sort_values(by='AvgGrowthRate')
style.use('seaborn-notebook')
combined.plot.barh(x='Nations', y='AvgGrowthRate')
plt.title('Average Annual Growth Rate by Top 10 Most Populous Countries')
plt.legend('')
plt.xlabel('Growth Rate in Percentage')
plt.ylabel('')
plt.show()
all_country_growth = cleaned_data.copy()[['Nation','Year1980', 'Year2010']]
all_country_growth = all_country_growth.dropna()
all_country_growth['Year1980'] = all_country_growth['Year1980'].str.replace('--', '0').astype(float)
all_country_growth['Year2010'] = all_country_growth['Year2010'].str.replace('--', '0').astype(float)

all_country_growth['GrowthRate'] = (all_country_growth['Year2010'] - all_country_growth['Year1980'])/(2010-1980)


top_10_lowest_growth = all_country_growth.sort_values(by='GrowthRate', ascending=True)
top_10_lowest_growth = top_10_lowest_growth[:10]
top_10_lowest_growth.plot.scatter(x='Nation', y='GrowthRate')
plt.title('Top 10 Lowest Populaton Growth Countries')
plt.xlabel('')
plt.xticks(rotation=45)
plt.ylabel('')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1804241435562806, 'fraction_numerical': 0.0730831973898858, 'mean_word_length': 7.4930747922437675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '280373', 'license': 'MIT', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1099, 'n_words': 187, 'path': 'world-population-exploratory.ipynb', 'repo_name': 'wphoong/world-population', 'size': '3065'}