Study Area: Mumbai¶

Temperature Data : 1980-2025¶

In [27]:
import pandas as pd
import hvplot.pandas
import holoviews as hv
import matplotlib.pyplot as plt
print("Imports successful!")
Imports successful!
In [28]:
mumbai_url = ('https://www.ncei.noaa.gov/access/services/'
           'data/v1?dataset=daily-summaries'
           '&dataTypes=TAVG,PRCP&stations=IN012070800'
           '&startDate=1980-10-01&endDate=2025-08-24')
mumbai_url
Out[28]:
'https://www.ncei.noaa.gov/access/services/data/v1?dataset=daily-summaries&dataTypes=TAVG,PRCP&stations=IN012070800&startDate=1980-10-01&endDate=2025-08-24'
In [29]:
mumbai_df= pd.read_csv(mumbai_url,
                       parse_dates=True,index_col="DATE")
mumbai_df
Out[29]:
STATION PRCP TAVG
DATE
1980-10-01 IN012070800 0.0 283
1980-10-02 IN012070800 41.0 277
1980-10-03 IN012070800 109.0 283
1980-10-04 IN012070800 0.0 283
1980-10-05 IN012070800 0.0 284
... ... ... ...
2025-08-20 IN012070800 2090.0 268
2025-08-21 IN012070800 249.0 275
2025-08-22 IN012070800 30.0 274
2025-08-23 IN012070800 51.0 279
2025-08-24 IN012070800 0.0 281

16361 rows × 3 columns

In [30]:
#ploting avg temperature data of Mumbai
mumbai_df.plot(y='TAVG')
Out[30]:
<Axes: xlabel='DATE'>
No description has been provided for this image
In [31]:
mumbai_df["TAVG_C"] = mumbai_df["TAVG"] / 10
mumbai_df
Out[31]:
STATION PRCP TAVG TAVG_C
DATE
1980-10-01 IN012070800 0.0 283 28.3
1980-10-02 IN012070800 41.0 277 27.7
1980-10-03 IN012070800 109.0 283 28.3
1980-10-04 IN012070800 0.0 283 28.3
1980-10-05 IN012070800 0.0 284 28.4
... ... ... ... ...
2025-08-20 IN012070800 2090.0 268 26.8
2025-08-21 IN012070800 249.0 275 27.5
2025-08-22 IN012070800 30.0 274 27.4
2025-08-23 IN012070800 51.0 279 27.9
2025-08-24 IN012070800 0.0 281 28.1

16361 rows × 4 columns

In [32]:
mumbai_df.plot(y='PRCP')
Out[32]:
<Axes: xlabel='DATE'>
No description has been provided for this image
In [33]:
mumbai_df.plot(y='TAVG_C')
Out[33]:
<Axes: xlabel='DATE'>
No description has been provided for this image
In [34]:
#Taking the TAVG_C Column only
mumbai_temp_df = mumbai_df[["TAVG_C"]]
mumbai_temp_df.head()
Out[34]:
TAVG_C
DATE
1980-10-01 28.3
1980-10-02 27.7
1980-10-03 28.3
1980-10-04 28.3
1980-10-05 28.4
In [35]:
#Taking Annual Mean Temperature
ann_mean_temp_df = mumbai_temp_df.resample('YE').mean()
ann_mean_temp_df
Out[35]:
TAVG_C
DATE
1980-12-31 26.789130
1981-12-31 27.355495
1982-12-31 27.201918
1983-12-31 26.412877
1984-12-31 27.060383
1985-12-31 26.978904
1986-12-31 27.127397
1987-12-31 27.775482
1988-12-31 27.215642
1989-12-31 27.012431
1990-12-31 27.076944
1991-12-31 26.933791
1992-12-31 27.109836
1993-12-31 27.175549
1994-12-31 26.939118
1995-12-31 27.254396
1996-12-31 27.636612
1997-12-31 27.657808
1998-12-31 27.746575
1999-12-31 27.651374
2000-12-31 27.609016
2001-12-31 27.256438
2002-12-31 27.819452
2003-12-31 27.463288
2004-12-31 27.003005
2005-12-31 27.358082
2006-12-31 27.355616
2007-12-31 28.023836
2008-12-31 27.748361
2009-12-31 28.334795
2010-12-31 28.161918
2011-12-31 27.938082
2012-12-31 27.605464
2013-12-31 27.633151
2014-12-31 28.184384
2015-12-31 28.671507
2016-12-31 28.243169
2017-12-31 28.553973
2018-12-31 28.763836
2019-12-31 28.266027
2020-12-31 28.398087
2021-12-31 28.562155
2022-12-31 28.247397
2023-12-31 28.903836
2024-12-31 28.486236
2025-12-31 28.472034
In [36]:
ann_mean_temp_df.plot(title='Average Temperature of Mumbai from 1980-2025')
Out[36]:
<Axes: title={'center': 'Average Temperature of Mumbai from 1980-2025'}, xlabel='DATE'>
No description has been provided for this image
In [37]:
#creating intercative plot
mumbai_plot = ann_mean_temp_df.hvplot(title='Average Temperature in Degree Celcius, Mumbai 1980-2025')
mumbai_plot
Out[37]:
In [38]:
# Save the map as a file
hv.save(mumbai_plot,'mumbai_plot.html')
In [39]:
%%capture
%%bash
#Coverting to HTML
jupyter nbconvert Climate-gaurav.ipynb --to html