So I've got a simple summary dataframe of sales by gender that goes:
Gender | Sales
___________________
M | 25
F | 30
All I want to do now is to return a line in Python that reads: The mean gap in the amount sold is 16.67%
This is simply 30 - 25 divided by 30, and multiplied by 100; and I want a % sign at the end.
I have tried:
m_sales = df.loc[df['Gender'] == 'M']
f_sales = df.loc[df['Gender'] == 'F']
print('The mean gap in the amount sold is:', m_sales['Sales'] - f_sales['Sales'] / m_sales['Sales'] * 100, '%')
Unfortunately this does not work. I get:
The mean gap in the amount sold is: 0 NaN 1 NaN Name: Sales, dtype: object %
Thoughts please? I am very much a beginner so sorry for such a basic query!