I'm trying to pull out the rows from these CSVs where the state is "Pennsylvania": https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_daily_reports_us
I have this code:
import glob
import pandas as pd
df = []
path = "/home/reallymemorable/Documents/git/COVID-19/csse_covid_19_data/csse_covid_19_daily_reports_us/*.csv"
for fname in glob.glob(path):
row = df.loc[df['Province_State'] == 'Pennsylvania']
print(row)
I'm getting this error:
AttributeError: 'list' object has no attribute 'loc'
I understand that it's expecting a DataFrame but I've set df as a list. But I don't know how to make it a DataFrame so that my pattern matching works correctly.
What am I doing wrong?