简体   繁体   中英

how can i index the adj close price to calculate the mean of one stock when i downloaded multiple tickers and grouped them by ticker?

I am trying to calculate the mean adj close of every ticker but I am not sure how to index the adj price

               ADDYY                          ...     BAS.DE                      
                  Open        High         Low  ...      Close  Adj Close     Volume
Date                                            ...                                 
2018-12-31  104.599998  105.050003  104.190002  ...        NaN        NaN        NaN
2019-01-02  105.419998  105.559998  104.449997  ...  60.720001  48.283272  2564044.0
2019-01-03  105.809998  105.889999  104.510002  ...  60.020000  47.726646  2213589.0
2019-01-04  107.550003  109.190002  107.550003  ...  63.189999  50.247360  4197991.0
2019-01-07  108.610001  109.180000  108.419998  ...  62.900002  50.016762  2437345.0
                ...         ...         ...  ...        ...        ...        ...
2019-12-25         NaN         NaN         NaN  ...        NaN        NaN        NaN
2019-12-26  162.059998  162.199997  160.850006  ...        NaN        NaN        NaN
2019-12-27  162.800003  163.570007  162.360001  ...  67.900002  56.472588  1640149.0
2019-12-30  164.000000  164.000000  162.009995  ...  67.349998  56.015144   936462.0
2019-12-31  161.990005  163.210007  161.990005  ...        NaN        NaN        NaN
adjClose = df.loc[:,"Adj Close"].copy()
 

should get you a new dataframe with just the column you want from each ticker, then

if this isn't the solution you need or you want to read up on it try searching "Hierarchical indexing"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM