Visualizing Weekly Temperature Patterns with Python and Matplotlib
import pandas as pd
import matplotlib.pyplot as plt

data = [
    ["2020-01-02 10:01:48.563", "22.0"],
    ["2020-01-02 10:32:19.897", "21.5"],
    ["2020-01-02 10:32:19.997", "21.0"],
    ["2020-01-02 11:34:41.940", "21.5"],
]

df = pd.DataFrame(data)
df.columns = ["timestamp", "temp"]
df["timestamp"] = pd.to_datetime(df["timestamp"])

df['Date'] = df['timestamp'].dt.date
df.set_index(df['timestamp'], inplace=True)

df['Weekday'] = df.index.day_name() 

for date in df['Date'].unique():
    df_date = df[df['Date'] == date]

    plt.figure()
    plt.plot(df_date["timestamp"], df["temp"])
    plt.title("{}, {}".format(date, df_date["Weekday"].iloc[0]))
    plt.show()

Last modified on 2023-07-25