0% found this document useful (0 votes)
14 views

LAB4TASK2.ipynb - Colaboratory

This document analyzes weather data over 100 days. It loads weather data from a CSV file and calculates summary statistics like the mean, median, range and interquartile range for temperature, humidity, wind speed and precipitation. It also generates box plots of each variable.

Uploaded by

205277
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

LAB4TASK2.ipynb - Colaboratory

This document analyzes weather data over 100 days. It loads weather data from a CSV file and calculates summary statistics like the mean, median, range and interquartile range for temperature, humidity, wind speed and precipitation. It also generates box plots of each variable.

Uploaded by

205277
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

3/7/24, 11:55 AM LAB4TASK2.

ipynb - Colaboratory

import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
import numpy as np

task2_df = pd.read_csv("task 2.csv")

task2_df.head(10)

Temperature Humidity Wind Speed Precipitation


Date
(°C) (%) (km/h) (mm)

2023-01-
0 28.943142 46.486830 11.563267 0.1
01

2023-01-
1 22.182549 69.133388 13.895300 0.0
02

2023-01-
2 20.482487 87.386971 7.819160 0.2
03

2023-01-
3 10.682536 56.131233 0.925924 0.0
04

2023-01-
4 18.613059 34.207950 8.788431 0.5
05

2023-01-
5 18.226205 33.463889 7.439606 20.0
06

2023 01

task2_df.describe()

Temperature (°C) Humidity (%) Wind Speed (km/h) Precipitation (mm)

count 100.000000 100.000000 100.000000 100.000000

mean 19.456815 58.927985 9.992345 2.418000

std 5.346768 18.214374 5.602454 4.841057

min 5.421311 30.044731 0.042511 0.000000

25% 15.699758 42.791823 5.029899 0.000000

50% 19.105180 58.213908 10.142427 0.200000

75% 23.384651 76.801620 14.165276 2.000000

max 30.790747 88.677145 19.762255 20.000000

task2_df.shape

(100, 5)

RANGE

temperature_range = task2_df["Temperature (°C)"].max() - task2_df["Temperature (°C)"].min()


temperature_range

25.36943546924816

Humidity_range = task2_df["Humidity (%)"].max() - task2_df["Humidity (%)"].min()


Humidity_range

58.63241325690521

Wind_Speed_range = task2_df["Wind Speed (km/h)"].max() - task2_df["Wind Speed (km/h)"].min()


Wind_Speed_range

19.719743886925386

Precipitation_range = task2_df["Precipitation (mm)"].max() - task2_df["Precipitation (mm)"].min()


Precipitation_range

https://colab.research.google.com/drive/1X8r4GH2gvB6BdiDhIF2m_s3chxfYn6Yg#scrollTo=I2dTNjQisftI&printMode=true 1/5
3/7/24, 11:55 AM LAB4TASK2.ipynb - Colaboratory

20.0

MID RANGE

mid_range = (task2_df["Temperature (°C)"].max() + task2_df["Temperature (°C)"].min()) / 2


mid_range

18.106028975660518

mid_range = (task2_df["Humidity (%)"].max() + task2_df["Humidity (%)"].min()) / 2


mid_range

59.36093795096649

mid_range = (task2_df["Wind Speed (km/h)"].max() + task2_df["Wind Speed (km/h)"].min()) / 2


mid_range

9.902383112780871

mid_range = (task2_df["Precipitation (mm)"].max() + task2_df["Precipitation (mm)"].min()) / 2


mid_range

10.0

IQR

q1 = task2_df["Temperature (°C)"].quantile(0.25)
q1

15.69975774532257

q3 = task2_df["Temperature (°C)"].quantile(0.75)
q3

23.384650999268366

iqr = q3 - q1
iqr

7.684893253945797

q1 = task2_df["Humidity (%)"].quantile(0.25)
q1
q3 = task2_df["Humidity (%)"].quantile(0.75)
q3
iqr = q3 - q1
iqr

34.009797754984504

q1 = task2_df["Wind Speed (km/h)"].quantile(0.25)


q1
q3 = task2_df["Wind Speed (km/h)"].quantile(0.75)
q3
iqr = q3 - q1
iqr

9.135376864054177

https://colab.research.google.com/drive/1X8r4GH2gvB6BdiDhIF2m_s3chxfYn6Yg#scrollTo=I2dTNjQisftI&printMode=true 2/5
3/7/24, 11:55 AM LAB4TASK2.ipynb - Colaboratory
q1 = task2_df["Precipitation (mm)"].quantile(0.25)
q1
q3 = task2_df["Precipitation (mm)"].quantile(0.75)
q3
iqr = q3 - q1
iqr

2.0

MAD

mad = task2_df["Temperature (°C)"].mad()


mad

<ipython-input-28-49bf2177e027>:1: FutureWarning: The 'mad' method is deprecated and will be removed in a future version. To compute th
mad = task2_df["Temperature (°C)"].mad()
4.330277484981561

mad = task2_df["Humidity (%)"].mad()


mad

<ipython-input-29-4213768d19b9>:1: FutureWarning: The 'mad' method is deprecated and will be removed in a future version. To compute th
mad = task2_df["Humidity (%)"].mad()
16.024148451677856

mad = task2_df["Wind Speed (km/h)"].mad()


mad

<ipython-input-30-28ff7a471582>:1: FutureWarning: The 'mad' method is deprecated and will be removed in a future version. To compute th
mad = task2_df["Wind Speed (km/h)"].mad()
4.686619891411592

mad = task2_df["Precipitation (mm)"].mad()


mad

<ipython-input-31-73074c8b083e>:1: FutureWarning: The 'mad' method is deprecated and will be removed in a future version. To compute th
mad = task2_df["Precipitation (mm)"].mad()
3.23608

PLOT BOX

plt.figure(figsize=(10, 6))
plt.boxplot(task2_df["Temperature (°C)"], patch_artist=True)
plt.title("Box Plot of Daily Temperatures")
plt.ylabel("Temperature (°C)")
plt.xticks([1], ['Temperature'])
plt.grid(True)

https://colab.research.google.com/drive/1X8r4GH2gvB6BdiDhIF2m_s3chxfYn6Yg#scrollTo=I2dTNjQisftI&printMode=true 3/5
3/7/24, 11:55 AM LAB4TASK2.ipynb - Colaboratory

plt.figure(figsize=(10, 6))
plt.boxplot(task2_df["Humidity (%)"], patch_artist=True)
plt.title("Box Plot of Daily Humidity")
plt.ylabel("Humidity (%)")
plt.xticks([1], ['Humidity (%)'])
plt.grid(True)

plt.figure(figsize=(10, 6))
plt.boxplot(task2_df["Wind Speed (km/h)"], patch_artist=True)
plt.title("Box Plot of Daily Wind Speed")
plt.ylabel("Humidity (%)")
plt.xticks([1], ['Wind Speed (km/h)'])
plt.grid(True)

https://colab.research.google.com/drive/1X8r4GH2gvB6BdiDhIF2m_s3chxfYn6Yg#scrollTo=I2dTNjQisftI&printMode=true 4/5
3/7/24, 11:55 AM LAB4TASK2.ipynb - Colaboratory

plt.figure(figsize=(10, 6))
plt.boxplot(task2_df["Precipitation (mm)"], patch_artist=True)
plt.title("Box Plot of Daily Precipitation ")
plt.ylabel("Precipitation (mm)")
plt.xticks([1], ['Precipitation (mm)'])
plt.grid(True)

https://colab.research.google.com/drive/1X8r4GH2gvB6BdiDhIF2m_s3chxfYn6Yg#scrollTo=I2dTNjQisftI&printMode=true 5/5

You might also like