import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
# Load the dataset
df = pd.read_csv('C:/Users/bharg/Downloads/Weater_Data.csv')
# Data Cleaning and Exploration
print(df.isnull().sum()) # Check for missing values
print(df.head()) # Display the first few rows
# Data Visualization
# Line graph for temperature over time
plt.figure(figsize=(12, 6))
plt.plot(df['Janurary'], df['Temperature_Avg'], label='Temperature
Avg')
plt.xlabel('Day in January')
plt.ylabel('Temperature Avg (°F)')
plt.title('Temperature Over Time in January')
plt.legend()
plt.show()
# Scatter plot for air quality vs. temperature
plt.figure(figsize=(10, 6))
sns.scatterplot(x='Temperature_Avg', y='pm25', data=df)
plt.xlabel('Temperature Avg (°F)')
plt.ylabel('pm25')
plt.title('pm25 vs. Temperature Avg')
plt.show()
# Interactive line chart using Plotly
fig = px.line(df, x='Janurary', y=['Temperature_Avg',
'Humidity_AVg(%)'],
title='Weather Trends Over Time', labels={'value':
'Values'},
line_dash='variable', template='plotly_dark')
fig.show()
# Correlation Heat Map using Seaborn
sns.set(style="white")
correlation_matrix = df.corr()
plt.figure(figsize=(10, 8))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm',
fmt=".2f")
plt.title('Correlation Heat Map')
plt.show()
Janurary 0
Temperature_Max(°F) 0
Temperature_Avg 0
Temperature_Min 0
pm25 0
pm10 0
o3 0
no2 0
so2 0
co 0
Humidity_Max(%) 0
Humidity_AVg(%) 0
Humidity_Min(%) 0
Wind_Speed_Max(mph) 0
Wind_Speed_Avgmph) 0
Wind_Speed_Min(mph) 0
Precipitation (in) 0
dtype: int64
Janurary Temperature_Max(°F) Temperature_Avg Temperature_Min
pm25 \
0 1 54 50.5 47
152
1 2 60 50.3 37
167
2 3 37 30.4 24
376
3 4 37 29.2 21
235
4 5 41 33.2 25
344
pm10 o3 no2 so2 co Humidity_Max(%) Humidity_AVg(%)
Humidity_Min(%) \
0 101 41 17 15 13 94 89.4
86
1 352 22 13 22 21 93 84.6
60
2 161 33 8 13 19 67 56.5
45
3 300 37 16 9 16 72 56.6
46
4 160 22 18 5 23 85 72.7
60
Wind_Speed_Max(mph) Wind_Speed_Avgmph) Wind_Speed_Min(mph) \
0 9 2.9 0
1 20 4.4 0
2 14 8.9 5
3 14 6.5 0
4 10 4.8 0
Precipitation (in)
0 0.01
1 0.77
2 0.00
3 0.00
4 0.00
{"config":{"plotlyServerURL":"https://plot.ly"},"data":
[{"hovertemplate":"variable=Temperature_Avg<br>Janurary=%
{x}<br>Values=%{y}<extra></
extra>","legendgroup":"Temperature_Avg","line":
{"color":"#636efa","dash":"solid"},"marker":
{"symbol":"circle"},"mode":"lines","name":"Temperature_Avg","orientati
on":"v","showlegend":true,"type":"scatter","x":
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
27,28,29,30,31],"xaxis":"x","y":
[50.5,50.3,30.4,29.2,33.2,31.6,26.7,24,30.9,27.6,20.8,25.7,33.4,34.9,1
6.9,19.8,34.3,32,34.3,32.8,18.3,18.8,27.8,29.7,32.5,21.4,22.3,30.8,21.
3,20.2,24.9],"yaxis":"y"},
{"hovertemplate":"variable=Humidity_AVg(%)<br>Janurary=%{x}<br>Values=
%{y}<extra></extra>","legendgroup":"Humidity_AVg(%)","line":
{"color":"#EF553B","dash":"dot"},"marker":
{"symbol":"circle"},"mode":"lines","name":"Humidity_AVg(%)","orientati
on":"v","showlegend":true,"type":"scatter","x":
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
27,28,29,30,31],"xaxis":"x","y":
[89.4,84.6,56.5,56.6,72.7,65.2,74.2,55.8,74.8,52,51.6,58.4,67.1,65.2,4
2.9,68.5,78.4,61.3,63.8,66,49.7,55,67.3,62.7,64.5,54.5,61.1,78.3,43.5,
50.1,57.7],"yaxis":"y"}],"layout":{"legend":{"title":
{"text":"variable"},"tracegroupgap":0},"template":{"data":{"bar":
[{"error_x":{"color":"#f2f5fa"},"error_y":
{"color":"#f2f5fa"},"marker":{"line":
{"color":"rgb(17,17,17)","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpo
lar":[{"marker":{"line":
{"color":"rgb(17,17,17)","width":0.5},"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"
carpet":[{"aaxis":
{"endlinecolor":"#A2B1C6","gridcolor":"#506784","linecolor":"#506784",
"minorgridcolor":"#506784","startlinecolor":"#A2B1C6"},"baxis":
{"endlinecolor":"#A2B1C6","gridcolor":"#506784","linecolor":"#506784",
"minorgridcolor":"#506784","startlinecolor":"#A2B1C6"},"type":"carpet"
}],"choropleth":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":
{"outlinewidth":0,"ticks":""},"colorscale":[[0,"#0d0887"],
[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],
[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],
[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],
[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":
{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],
"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":
{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":
{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":
[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"line":
{"color":"#283442"}},"type":"scatter"}],"scatter3d":[{"line":
{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":
[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":
[{"marker":{"line":
{"color":"#283442"}},"type":"scattergl"}],"scattermapbox":[{"marker":
{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar"
:[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl
":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterterna
ry":[{"marker":{"colorbar":
{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":
[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],
[1,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":
{"color":"#506784"},"line":{"color":"rgb(17,17,17)"}},"header":
{"fill":{"color":"#2a3f5f"},"line":
{"color":"rgb(17,17,17)"}},"type":"table"}]},"layout":
{"annotationdefaults":
{"arrowcolor":"#f2f5fa","arrowhead":0,"arrowwidth":1},"autotypenumbers
":"strict","coloraxis":{"colorbar":
{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":
[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],
[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],
[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]],"sequentialminus":
[[0,"#0d0887"],[0.1111111111111111,"#46039f"],
[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],
[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],
[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],
[0.8888888888888888,"#fdca26"],[1,"#f0f921"]]},"colorway":
["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692"
,"#B6E880","#FF97FF","#FECB52"],"font":{"color":"#f2f5fa"},"geo":
{"bgcolor":"rgb(17,17,17)","lakecolor":"rgb(17,17,17)","landcolor":"rg
b(17,17,17)","showlakes":true,"showland":true,"subunitcolor":"#506784"
},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":
{"style":"dark"},"paper_bgcolor":"rgb(17,17,17)","plot_bgcolor":"rgb(1
7,17,17)","polar":{"angularaxis":
{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"bgcolor":"rg
b(17,17,17)","radialaxis":
{"gridcolor":"#506784","linecolor":"#506784","ticks":""}},"scene":
{"xaxis":
{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2
,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor
":"#C8D4E3"},"yaxis":
{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2
,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor
":"#C8D4E3"},"zaxis":
{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2
,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor
":"#C8D4E3"}},"shapedefaults":{"line":
{"color":"#f2f5fa"}},"sliderdefaults":
{"bgcolor":"#C8D4E3","bordercolor":"rgb(17,17,17)","borderwidth":1,"ti
ckwidth":0},"ternary":{"aaxis":
{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"baxis":
{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"bgcolor":"rg
b(17,17,17)","caxis":
{"gridcolor":"#506784","linecolor":"#506784","ticks":""}},"title":
{"x":5.0e-2},"updatemenudefaults":
{"bgcolor":"#506784","borderwidth":0},"xaxis":
{"automargin":true,"gridcolor":"#283442","linecolor":"#506784","ticks"
:"","title":
{"standoff":15},"zerolinecolor":"#283442","zerolinewidth":2},"yaxis":
{"automargin":true,"gridcolor":"#283442","linecolor":"#506784","ticks"
:"","title":
{"standoff":15},"zerolinecolor":"#283442","zerolinewidth":2}}},"title"
:{"text":"Weather Trends Over Time"},"xaxis":{"anchor":"y","domain":
[0,1],"title":{"text":"Janurary"}},"yaxis":{"anchor":"x","domain":
[0,1],"title":{"text":"Values"}}}}