<jupyter_start><jupyter_text>Day 10---<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
!dir
pd.read_csv('Metadata_Country_API_EN.ATM.CO2E.KT_DS2_en_csv_v2.csv')
pd.read_csv('Metadata_Indicator_API_EN.ATM.CO2E.KT_DS2_en_csv_v2.csv')
df = pd.read_csv('API_EN.ATM.CO2E.KT_DS2_en_csv_v2.csv')
!head API_EN.ATM.CO2E.KT_DS2_en_csv_v2.csv
df = pd.read_csv('API_EN.ATM.CO2E.KT_DS2_en_csv_v2.csv', skiprows=3)
df.head()
df[df["Country Name"] == 'Nepal']
ndf = df[df["Country Name"] == 'Nepal']
ndf.plot()df[df["Country Name"] == 'Nepal']df[df["Country Name"] == 'Nepal']
ndf.T
ndf.drop(['Country Name', 'Country Code', 'Indicator Name', 'Indicator Code'])
ndf
ndf.drop(['Country Name', 'Country Code', 'Indicator Name', 'Indicator Code'], axis=1)
ndf
ndf.drop(['Country Name', 'Country Code', 'Indicator Name', 'Indicator Code'], axis=1, 
         inplace=True)
ndf
ndf = ndf.T
ndf
ndf.columns = ['Emission']
ndf
ndf.dropna(inplace=True)
ndf
ndf.plot()
ndf.index
country_df = pd.read_csv('Metadata_Country_API_EN.ATM.CO2E.KT_DS2_en_csv_v2.csv')
country_df.head()
sa_countries = country_df[country_df['Region'] == 'South Asia']['Country Code']
sa_countries
df.head()
df[df['Country Code'].isin(sa_countries.values)]
sdf = df[df['Country Code'].isin(sa_countries.values)]
sdf.drop(['Country Name', 'Country Code', 'Indicator Name', 'Indicator Code'], axis=1)
sdf.head()
sdf.set_index('Country Name')
sdf
sdf.set_index('Country Name', inplace=True)
sdf
sdf.drop(['Country Code', 'Indicator Name', 'Indicator Code'], axis=1, inplace=True)
sdf.head()
sdf = sdf.T
sdf
sdf.dropna(inplace=True)
sdf
sdf.plot()
import seaborn as sns
sns.set()
sdf.plot()
sdf[['Bangladesh', 'Nepal', 'Pakistan', 'Bhutan']]
sdf[['Maldives', 'Nepal', 'Sri Lanka', 'Bhutan']].plot()
sdf.plot(kind='bar')<jupyter_output><empty_output><jupyter_text>Alternative method<jupyter_code>df.head()
country_df.head()
pd.merge(df, country_df).head()<jupyter_output><empty_output><jupyter_text>pd.merge(df, country_df, on='Country Name')<jupyter_code>sdf.head()
sdf.columns
sdf.columns.difference(['India'])
sdf[sdf.columns.difference(['India', 'Pakistan'])]
sdf.loc['2000':'2013']
sdf.loc['2000':'2013'].sum()
sdf.loc['2000':'2013'].sum(axis=1)
sdf.loc['2000':'2013'].sum().plot(kind='bar')
sdf2 = sdf.loc['2000':'2013']
sdf2 = sdf2[sdf2.columns.difference(['India'])]
sdf2
sdf2.sum().plot(kind='bar')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1958128078817734, 'fraction_numerical': 0.029556650246305417, 'mean_word_length': 7.829710144927536, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '421728', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1031, 'n_words': 163, 'path': 'Sessions/Day-10.ipynb', 'repo_name': 'rprasai/datascience', 'size': '2436'}