I'm doing a basics in python course and trying to complete the challenge we've been set. I need to determine the average sale price for each product category after reading a sales data spreadsheet. I can read the spreadsheet and I know how to separate out the category column using .groupby . But I can't make it work out the average sale price as it tries to do it on the category column which is a string. I've put the code below. Any help would be appreciated. Thanks
import pandas as pd
def read_data():
df = pd.read_csv('sales_dataset.csv')
print(df)
return df
read_data()
def average_price():
df = read_data()
average = df.groupby(["Sale Price"]).mean()
print(average)
return average
average_price()
I thought I was following the code that would calculate an average sale price for each product category listed in a spreadsheet. It tried to do it on the category column, which is a string and not the sale price column.