简体   繁体   English

当我下载多个代码并按代码分组时,如何索引调整收盘价以计算一只股票的平均值?

[英]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应该给你一个新的 dataframe ,其中只有你想要的每个股票的列,然后

if this isn't the solution you need or you want to read up on it try searching "Hierarchical indexing"如果这不是您需要的解决方案或者您想阅读它,请尝试搜索“分层索引”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我有一个带有代码列和日期列的 dataframe 表。 我想计算相应日期的股票价格 - I have a dataframe table with a ticker column and a date column. I want to calculate the price of the ticker at the corresponding date 我可以从 yahoo Finance 加载多个股票代码,但在将新列保存到 csv 之前添加新列时遇到问题 - I can load multiple stock tickers from yahoo finance, but I am having trouble adding new columns before it is saved to a csv 如何使用 Python 下载股票价格数据? - How can I download stock price data with Python? 当两个numpy数组之一具有NAN值时,如何计算相关系数? - How can I calculate the correlation coefficient between 2 numpy arrays when one of them has NAN values? 当每条线都有不同的代码和日期时如何拉动股价? - How to pull stock price when each line has a different ticker and date? 如何计算股票价格的趋势线 - How to calculate the trendline for stock price 我怎样才能拆分价格以获得一个价格 - How can I split the price to get one price 我如何更正我的 output 以便它返回指定的类别以及字典中相应的代码价格总和? - How do I correct my output so that it returns the specified categories with the corresponding tickers price sums inside the dictionary? 如何从我的代码中解决此错误 KeyError Date Adj Close not found in axis - How do I solve this error from my code KeyError Date Adj Close not found in axis 我怎样才能最好地删除具有不同值的行分组在一个上,但即使它出现多个时间分组在一个值上,也要保持相同的值 - How can I best remove lines with different values grouped on one, but keep the same value even if it appears multiple time grouped on one value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM