-3

I'm trying to find mean price for specific stock.

enter image description here

How do get mean price of APPL?

I'm trying:

price_data= data['stock'=='AAPL','price']

I'm still trying to get it, but I'm getting an error:

header 1 header 2
cell 1 cell 2
cell 3 cell 4
4
  • 1
    pandas.pydata.org/pandas-docs/stable/reference/api/… Commented Apr 17, 2024 at 4:00
  • Please provide enough code so others can better understand or reproduce the problem. Commented Apr 17, 2024 at 5:19
  • 1
    Welcome to SO! Please edit your post so as to share all code, data and error tracebacks as text, not images. That includes the initial dataframe. To share dataframes: copy-paste the output of print(data.head()). Commented Apr 17, 2024 at 5:21
  • Use price_data= data.loc['stock'=='AAPL','price'].mean() Commented Apr 17, 2024 at 5:28

1 Answer 1

0
data.groupby('stock')['price'].mean()
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.