1
$\begingroup$
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?

$\endgroup$

1 Answer 1

0
$\begingroup$
df.groupby(df.Trend).mean()['Total Traded Quantity']
df.groupby(df.Trend).median()['Total Traded Quantity']

or

df_trend_average = df.groupby(df.Trend).mean()
df_trend_median = df.groupby(df.Trend).median()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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