Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import matplotlib.pyplot as plt
- df = pd.read_csv("viral_load_data.csv")
- df["date"] = pd.to_datetime(df["date"])
- # ensure uniform spacing
- df = df.sort_values("date")
- df = df.set_index("date").asfreq("D").interpolate().reset_index()
- plt.figure(figsize=(16, 6))
- plt.plot(df["date"], df["value"])
- plt.title("SARS-CoV-2 Viral Load Index")
- plt.xlabel("Date")
- plt.ylabel("Viral Load Index")
- plt.ylim(0, 0.85) # top bar
- plt.grid(True)
- plt.tight_layout()
- plt.savefig("viral_load_chart.png", dpi=300)
- plt.show()
Advertisement