<jupyter_start><jupyter_text>"Air Quality Index in India Blog"> "Welcome to the first blog on the Air Quality Index of India during 2015-2020."<jupyter_code>import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline 

#keeping the graphs intact along with the notebook and accessing the inline utilitiies from the backend.<jupyter_output><empty_output><jupyter_text>Accessing the AQI data on daily basis with respect to different cities.<jupyter_code>df = pd.read_csv(r'C:\Users\Ankan\Desktop\Air Quality Index/city_day.csv')
df_city_day = df.copy()
df_city_day.head()
df_city_day.info()
df_city_day.isnull().sum()<jupyter_output><empty_output><jupyter_text>We can see that Xylene and PM10 have the most null values(18K and 11K) respectively.<jupyter_code>df_city_day['AQI_Bucket'].value_counts(ascending= True)<jupyter_output><empty_output><jupyter_text>Mainly there are six categories of AQI which we observe: *Good, Satisfactory, Moderate, Poor, Very Poor and Severe.*<jupyter_code>sns.catplot(x = "AQI_Bucket", kind= "count", palette = "ch: 2.87", height=5, aspect=1.1, data = df_city_day)<jupyter_output><empty_output><jupyter_text>**Plot: Number of entries vs AQI_Bucket Catogory** Let us drop those null values which have the least part to play in the analysis of AQI.<jupyter_code>df_city_day = df_city_day.dropna(axis = 0, subset = ['PM10'])
df_city_day = df_city_day.dropna(axis = 0, subset = ['Xylene'])
df_city_day.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 7314 entries, 1594 to 29529
Data columns (total 16 columns):
 #   Column      Non-Null Count  Dtype  
---  ------      --------------  -----  
 0   City        7314 non-null   object 
 1   Date        7314 non-null   object 
 2   PM2.5       7210 non-null   float64
 3   PM10        7314 non-null   float64
 4   NO          7306 non-null   float64
 5   NO2         7234 non-null   float64
 6   NOx         7226 non-null   float64
 7   NH3         6906 non-null   float64
 8   CO          7257 non-null   float64
 9   SO2         7149 non-null   float64
 10  O3          7124 non-null   float64
 11  Benzene     7312 non-null   float64
 12  Toluene     7314 non-null   float64
 13  Xylene      7314 non-null   float64
 14  AQI         7145 non-null   float64
 15  AQI_Bucket  7145 non-null   object 
dtypes: float64(13), object(3)
memory usage: 971.4+ KB<jupyter_text>We would analyse the contribution of these major pollutants city-wise.<jupyter_code>df_city_day[['PM2.5', 'City']].groupby(['City']).median().sort_values("PM2.5", ascending = False).plot.bar()<jupyter_output><empty_output><jupyter_text>*Delhi* has the **highest levels of PM2.5** whereas Mumbai and Ernakulam turn out to be on the other side of the table. Major reasons behind the rise of PM2.5 levels in Delhi are increasing traffic, dust and smoke from fires.<jupyter_code>df_city_day[['NO', 'City']].groupby(['City']).median().sort_values("NO", ascending = False).plot.bar(color='brown')<jupyter_output><empty_output><jupyter_text>*Mumbai* has the **highest levels of NO** whereas Gurugram and Amaravati have quite minimal figures. Major spike of NO in the commercial capital of India are causing *respiratory ailments, hematologic side effects, metabolic disorders, low blood pressure, nausea, vomiting and diarrhoea.*<jupyter_code>df_city_day[['NO2', 'City']].groupby(['City']).median().sort_values("NO2", ascending = False).plot.bar(color='purple')
df_city_day[['CO', 'City']].groupby(['City']).median().sort_values("CO", ascending = False).plot.bar(color='y')
df_city_day[['SO2', 'City']].groupby(['City']).median().sort_values("SO2", ascending = False).plot.bar(color='r')
df_city_day[['O3', 'City']].groupby(['City']).median().sort_values("O3", ascending = False).plot.bar(color='orange')
df_city_day[['Benzene', 'City']].groupby(['City']).median().sort_values("Benzene", ascending = False).plot.bar(color='teal')<jupyter_output><empty_output><jupyter_text>Ahmedabad has the highest stake when **nitrogen dioxides, sulphur dioxides and carbon monoxide** is concerned, whereas Gurugram and Kolkata are the most polluted due to **ozone** and **benzene** respectively. On a broader view, Ernakulam and Amaravati seem to be less hazardous compared to other mid-tier and top-tier cities.<jupyter_code>sns.set()
cols = ['SO2', 'NOx', 'O3', 'NO2', 'PM2.5']
sns.pairplot(df_city_day[cols], height = 2.5)
plt.show()<jupyter_output><empty_output><jupyter_text>We see that SO2 and NO2 are more concentrated towards the origin, hence sensing to be somewhat correlated. While for others, there is no clear indication since they are widely scattered.<jupyter_code>corrmat = df_city_day.corr()
heatmap_df= corrmat.drop(['NOx', 'NH3','O3','Toluene','Xylene', 'AQI']).drop(['NOx', 'NH3','O3','Toluene','Xylene', 'AQI'], axis=1)
f, ax = plt.subplots(figsize = (10,10))
sns.heatmap(heatmap_df, vmax = 1, square = True, annot = True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12955139810903238, 'fraction_numerical': 0.04083685375176021, 'mean_word_length': 4.877068557919622, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 42, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '25930', 'license': 'Apache-2.0', 'n_tokens_mistral': 1862, 'n_tokens_neox': 1668, 'n_words': 470, 'path': '_notebooks/2022-02-04-AQI-India-Blog.ipynb', 'repo_name': 'Ankan-238/aqi_index_blog', 'size': '4971'}