So basically, I'm writing out statistics.
date,students
2022-11-16,22
2022-11-17,29
I want to read this csv back in and pull the col2 value from "yesterdays" row and compare it to the col2 value from "todays" row and look for a threshold difference. Something like a 5% variance. The last part is straightforward but I'm having a heck of a time with pulling the right rows and re-capturing the 'student' count for comparison.
I can do the hunt operation good enough with Pandas but I lose the second column in the match and its just not clicking for me.
import pandas as pd
from datetime import date
from datetime import timedelta
today = date.today()
yesterday = date.today() - timedelta(1)
print("today is ", today, " and yesterday was ", yesterday)
df = pd.read_csv('test.csv')
col1 = df.timestamp
col2 = df.hostcount
for row in col1:
if row == str(yesterday):
print(row)
Any ideas are greatly appreciated! I'm sure this is something goofy that I'm overlooking at 1am.