0% found this document useful (0 votes)
3 views1 page

Final409 (Python)

The document contains a Python script that analyzes rainfall data from a spreadsheet for the station 'Khulna'. It calculates the average monthly rainfall for two decades (1981-1990 and 2014-2023) and visualizes the difference using a bar chart. The chart displays the change in monthly rainfall between the two decades.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Final409 (Python)

The document contains a Python script that analyzes rainfall data from a spreadsheet for the station 'Khulna'. It calculates the average monthly rainfall for two decades (1981-1990 and 2014-2023) and visualizes the difference using a bar chart. The chart displays the change in monthly rainfall between the two decades.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import pandas as pd

import [Link] as plt

df = pd.read_excel("[Link]")

## Convert object to numeric, coerce-- N/A data to NaN data. then it will not count as data.

df["Max_T"]=pd.to_numeric(df["Max_T"], errors="coerce")
df["Min_T"]=pd.to_numeric(df["Min_T"], errors="coerce")
df["Rain"]=pd.to_numeric(df["Rain"], errors="coerce")

def get_station_data(station_name):
return df[df["Station"] == station_name].reset_index(drop=True)

khulna = get_station_data("Khulna")

first_decade = khulna[(khulna["Year"] >= 1981) & (khulna["Year"] <= 1990)]


first_decade_mean = first_decade.groupby("Month")["Rain"].mean()

last_decade = khulna[(khulna["Year"] >= 2014) & (khulna["Year"] <= 2023)]


last_decade_mean = last_decade.groupby("Month")["Rain"].mean()

rain_diff = last_decade_mean - first_decade_mean

[Link](rain_diff.index, rain_diff.values, color="tomato")

[Link]("Month")
[Link]("Rainfall Difference")

[Link]("Decadal Change in Monthly Rainfall - Khulna\nLast Decade is 2014-2023 and 1st decade
is 1981-1990")
[Link]()

You might also like