I need to calculate an average of two columns 'Height(Inches)' and 'Weight(Pounds)', when i use the code below , i getting the error 500 'Internal Server Error'.
@app.route('/csv')
def get_average_parameters():
dataset = pd.read_csv('hw.csv')
average = dataset[['Height(Inches)', 'Weight(Pounds)']].mean()
return str(average)
But when use 'average' without columns sigs:
@app.route('/csv')
def get_average_parameters():
dataset = pd.read_csv('hw.csv')
average = dataset.mean()
return str(average)
I didn't get any error, and output looks like this:
Index 12500.500000 Height(Inches) 67.993114 Weight(Pounds) 127.079421 dtype: float64
How can I get the averages of two columns 'Height(Inches)' and 'Weight(Pounds)' without errors?