0 ratings 0% found this document useful (0 votes) 11 views 4 pages Rain Fall
The document is a Jupyter Notebook for analyzing rainfall data in India from 1981 to 2015 using Google Colaboratory. It includes code for uploading data, importing libraries, and visualizing monthly and annual rainfall trends for various subdivisions, particularly focusing on Kerala. The notebook demonstrates data manipulation and plotting techniques using pandas and matplotlib libraries.
AI-enhanced title and description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
sr10123, 2:08 PM IP PROJECT RAINFALL ipynb -Colaboratory
4#To upload from your local drive, start with the following code:
from google.colab inport #
uploaded = files.upload()
No fle chosen Upload widget is only available when the
cell has been executed in the current browser session. Please rerun this call to
enable
» IMPORTING THE LIBRARIES
import natplotlib.pyplot as pit
import pandas as pd
import numay as np
Importing data from a cs file and displaying it
df-pd.read_csv(*rainfall in india 1981-2615.csv"
af
e
SUBDIVISION YEAR JAN FEB MAR APR MAY JUN JL
ANDAMAN &
° NICOBAR 1901 492 87.1 292 23 5288 S175 365
ISLANDS
ANDAMAN &
1 NICOBAR 1902 0.0 1598 122 0.0 446.1 537.1 228
ISLANDS
ANDAMAN &
2 NICOBAR 1903 127 144.0 0.0 1.0 235.1 4799 728
ISLANDS
ANDAMAN &
3 NICOBAR 1904 9.4 147 0.0 2024 3085 495.1 502
ISLANDS
ANDAMAN &
4 NICOBAR 1905 13 00 33 269 2795 6287 968
ISLANDS
4111 LAKSHADWEEP 2011 51 28 31 85.9 107.2 1536 350
4112 LAKSHADWEEP 2012 192 01 16 768 212 327.0 231
4113 LAKSHADWEEP 2013 262 344 375 5.3 883 426.2 296
4114 LAKSHADWEEP 2014 532 16.1 44 149° 574 2481 116
4115 LAKSHADWEEP 2015 22 05 37 87.1 133.1
257
4116 rows «19 columns
df.dtypes.
SUBDIVISION object
YEAR inte.
AN Floates
Fee Floates
MAR Floatss
APR floatea
may Floates
hntps:ifcola.research.google.comicrvel15G4sFoKa8JPhdpnL ABG7reU 1nOZaPIKvitorinMode=ttue
asr10123, 2:08 PM IP PROJECT RAINFALL ipynb -Colaboratory
aN Aloates
aut Floates
AUG Floatsa
seP Floates
ocr Floatss
Nov Floatss
vec floates
ANKUAL floates
Jan-Feb Floates
Mar-May floates
dun-Sep Floatea
Oct-Dec Floated
type: object
df.colunns
Index({ ‘SUBDIVISION’, "YEAR", "JAN", "FEB", "MAR", APR, ‘MAY', “JUN', "JUL",
‘AUG", "SEP", "0cT’
"Sun-Sep', "Oct-Dec" ],
atype="object")
svoct’, ‘nov, “orc, *anwual*, "aan-Feb*, *Mar-May”,
df, SUBDIVISION. unique()
array(['ANOAMAN & NICOBAR ISLANDS’, "ARUNACHAL PRADESH’ ,
"ASSAM & MEGHALAVA', 'NAGA MANI MEZO TRIPURA',
SUB HIMALAVAN WEST BENGAL & SIKKIM", ‘GANGETIC WEST BENGAL’,
ORISSA’, “JHARKHAND’, “BIHAR”, "EAST UTTAR PRADESH”
WEST UTTAR PRADESH", “UTTARAKHAND", "HARVANA DELHI & CHANDIGARH’ ,
"PUNJAB", "HIMACHAL PRADESH", "JAMMU & KASHMIR", "WEST RAJASTHAN",
“EAST RAJASTHAN’, “WEST MADHVA PRADESH’, "EAST MADHYA PRADESH’ ,
“GUDARAT REGION", "SAURASHTRA & KUTCH", "KONKAN & GOA"
MADHYA MAARASHTRA', “MATATHWADA', “VIOARBHA', ‘CHAT
COASTAL ANDHRA PRADESH", "TELANGANA’, "RAYALSEEMA', *
‘COASTAL KARNATAKA’, "NORTH INTERIOR KARNATAKA
"SOUTH INTERIOR KARNATAKA, "KERALA", "LAKSHADAEEP"], dtype=object)
dfkerala=df[dF{ ‘SUBDIVISION’ }
dfkerala.tail(1@)
KERALA]
SUBDIVISION YEAR JAN FEB MAR APR MAY «JUN JUL AUG
3992 KERALA 2008 81 05 907 65.3 5212 482.4 8040 4326
3993 KERALA 2007 05 56 73 1985 1927 705.9 9653 4896
3994 KERALA 2008 08 903 2172 1084 812 469.9 5051 3490
3995 KERALA 2009 33 15 626 690 1916 4982 9249 2693
KERALA 2010 186 1.0 314 1989 1906 667.5 629.0 3560
KERALA 2011 205 45.7 241 1052 1262 7885 5368 4927
3998 KERALA 2012 74 11.0 210 1711 95.8 490.8 3625 5016
3999 KERALA 2013 39 40.1 499 493 1198 1042.7 8302 3697
4000 KERALA 2014 46 108 179 957 251.0 4584 677.8 7339
4001 «KERALA 2015 31 5.8 50.1 214.1 2018 583.6 4080 252.2
+ ANNUAL RAINFALL COMPARISON
Data visualsation using columns as x and y axis on the graph
hntps:ifcola.research.google.comicrvel15G4sFoKa8JPhdpnLABG7reU 1nOZaPIKviprinMode=ttue
sep
ama
526.7
347.0
926.5
278.6
391.2
2a
3186
208.8
202.9sr10123, 2:08 PM IP PROJECT RAINFALL ipynb -Colaboratory
dfkerala[ [ YEAR’ ,"ANNUAL']] .plot(kinds Line’ ,x=" YEAR")
NAL
000
3500
2000
200
10s) se) —«se) OD 20
> MONTHLY RAINFALL
plotting a graph using values in a given row
Double-click (or enter) to edit
asint(input("enter the year (3980-2615):"))
dfy.tloc[@,2:14] .plot(kind= bar’)
plt.title(*vonthly Rainfall \n %4"X(a))
enter the year (1900-2015) :2000
Text(@.5, 1.8, ‘Monthly Rainfall \n 2000")
Monthly Rainfall
2000,
0
300
200
100
REPE PRS SHEE E
dfy2=dfKerala[dfKerala[ "YEAR"
dfy3-dfKeralaldfKeralal "YEAR"
Xe['Jan", "FEB", "PAR", “APR, "MAY", "3UN', "JUL", "AUG", “SEP", "OCT", "NOV" ,‘DEC*]
plt.figure(figsize-(18,6))
plt.suptitle("Monthly Rainfall \n
pit. subplot(134)
plt.title(*2a10")
plt.bar(x,dFy2.4loc(@,:
4], color="k")
pit. subplot(132)
pit title("2@23")
plt.plot(x, dfy2.tloc(a,2:14], ‘g.
hntps:ifcola research google.comicrvel15G4sFoKa8JPbdpnL ASG7reU InOZaPIKviorintMode=ttue
3asr10123, 2:08 PM IP PROJECT RAINFALL ipynb -Colaboratory
plt.subplot(233)
c1e("2012")
plot(x, dfy3.iloc[@,2:14], 'r-*")
[cnatplotlib.Lines.Line2 at @x7fbd3942a2b0>1
a a i. " oe z
Colab paid products - Cancel contracts here
hnttps:ifcolab research google.com/erve/15G4sFoKa8,JPbdpnl ABG7raU InOZaPIKviprin’Modestue
48
You might also like Pivot, Pivot Table, Interpolation, Groupby, Heatmaps, Merge PDF
Pivot, Pivot Table, Interpolation, Groupby, Heatmaps, Merge
99 pages