df_trend = df.groupby(["Trend"])
average_trades = df_trend["Total Traded Quantity"].mean()
print("The average traded quantity is: ", average_trades)

>>The average traded quantity is:  Trend
Slight or No Change    1.635627e+06
Name: Total Traded Quantity, dtype: float64

But I have 9 types of trends in Trend column, although I get only one type here in the output. How shall I proceed?

df.groupby(df.Trend).mean()['Total Traded Quantity']
df.groupby(df.Trend).median()['Total Traded Quantity']


df_trend_average = df.groupby(df.Trend).mean()
df_trend_median = df.groupby(df.Trend).median()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.