I've started using pandas this week so pardon me if I'm asking a really obvious question. I am trying to get pandas to loop through all the sheets in my Excel wb to extract a specific column, column F for counts of occurances via value_counts.
Previously I used value_counts and typed in the specific name of the worksheet and it worked in pulling out the value count of that 1 sheet. However, the minute I replaced the sheet name to df1, it stops working.
df = pd.ExcelFile("filepath.xlsx")
for df1 in df.sheet_names:
df2 = pd.read_excel("filepath.xlsx", sheet_name=df1, usecols="F")
df2.dropna(inplace=False)
print (df2.value_counts())
I expect the output to be the unique values and their occurance numbers but it returns:
AttributeError: 'DataFrame' object has no attribute 'value_counts'
Can somebody please help me?