
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.preprocessing import MinMaxScaler
df = pd.DataFrame({ "temp": [22, 23, np.nan, 25, 100, 24, 23, 22], "hum": [55, 56, 54, np.nan, 300, 57, 58, 59] })
df = df[(df["temp"] < 50) & (df["hum"] < 100)]
df.fillna(df.median(), inplace=True)
df.reset_index(drop=True, inplace=True)
scaler = MinMaxScaler() df[["temp_n", "hum_n"]] = scaler.fit_transform(df[["temp", "hum"]])
plt.plot(df["temp_n"], label="Temp") plt.plot(df["hum_n"], label="Humidity") plt.xlabel("Sample Index") plt.ylabel("Normalized Value (0-1)") plt.title("Cleaned & Normalized IoT Sensor Data") plt.legend() plt.show()