【问题标题】:Plotting dataframe with paramater用参数绘制数据框
【发布时间】:2021-02-21 10:02:35
【问题描述】:

这是我的数据框

bedrijf = 公司

我需要创建一个将股票代码作为参数的函数(例如 TNET)并创建一个图表 以该股票的价格。这是开始的:

def graph(ticker):

stock = pd.DataFrame()
# needs to be replaced with the right code

# assuming the variable stock
# is a dataframe with the data of the stock as a row
# with the specified ticker, the code below ensures
# that x-Axis (xAs) contains the names of the columns and y-Axis (yAs) contains the values ​​in those columns

xAs = stock.columns[2:26]
yAs = stock.iloc[0,2:26]

【问题讨论】:

    标签: python pandas dataframe matplotlib graph


    【解决方案1】:

    如果ticker 是一列,那么stock[stock['Ticker']==ticker] 是带有输入代码价格的数据框。

    如果ticker是索引,那么stock.loc[ticker]将完成这项工作。

    【讨论】:

      猜你喜欢
      • 2016-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-03
      • 2017-02-19
      • 2018-04-08
      • 2020-08-23
      • 2015-09-29
      相关资源
      最近更新 更多