fig = go.Figure()
fig.add_trace(
go.Scatter(x=alldates, y=countriesData[0]["ToxPi Score"],
name="Suffolk",customdata=countriesData[0],hovertemplate=common_template)
)
fig.update_xaxes(
rangeslider_visible=True,
rangeselector=dict(
buttons=list([
dict(count=1, label="1m", step="month", stepmode="backward"),
dict(count=6, label="6m", step="month", stepmode="backward"),
dict(count=1, label="YTD", step="year", stepmode="todate"),
dict(count=1, label="1y", step="year", stepmode="backward"),
dict(step="all")
])
)
)
fig.show()

我的数据框架看起来像这样
我正在研究一个简单的数据集,在该数据集中,我根据日期绘制了状态的TOXPI分数。
现在,我需要根据给定的方向将这些数据绘制为烛台格式
开放式值:在给定7天的给定范围内的第一天TOXPI值。
接近值:在给定范围为7
天。
高值:在给定7天的给定范围内的最高毒素值。
低值:给定7天的最低毒品值。
我无法弄清楚如何掩盖它或将数据分为每周格式
编辑
看起来像这样

请帮忙
提前。
fig = go.Figure()
fig.add_trace(
go.Scatter(x=alldates, y=countriesData[0]["ToxPi Score"],
name="Suffolk",customdata=countriesData[0],hovertemplate=common_template)
)
fig.update_xaxes(
rangeslider_visible=True,
rangeselector=dict(
buttons=list([
dict(count=1, label="1m", step="month", stepmode="backward"),
dict(count=6, label="6m", step="month", stepmode="backward"),
dict(count=1, label="YTD", step="year", stepmode="todate"),
dict(count=1, label="1y", step="year", stepmode="backward"),
dict(step="all")
])
)
)
fig.show()

My dataframe looks like this

I am working on a simple dataset in which i have plotted ToxPi score of a state according to dates.
Now i need to plot this data into candlestick format according to given directions
Open value: ToxPi value at the first day in a given range of 7 days.
Close value: ToxPi value at the last (7th) day in a given range of 7
days.
High value: The highest ToxPi value in a given range of 7 days.
Low value: The lowest ToxPi value in a given range of 7 days.
I can't figure out the way how to covert it or separate the data into weekly format
EDIT
After updating datetime column in df it looks like this

Please Help
Thanx in advance.
发布评论
评论(1)
尽管我对“给定7天的范围”的含义并不完全清楚,但我的猜测是应该使用7天的滚动计算来计算开放,高,低和关闭,并且您的数据具有谷物1天。
我不确定您的
nestoryData [0]
有一个DateTime列,因此我们将使用alldates
您传递给go.scatter
go.scatter :然后,您可以使用修改后的数据框来构建烛台图:
Although I am not completely clear in what is meant by a "given range of 7 days", my guess is that a 7 day rolling calculation should be used to calculate open, high, low, and close, and that your data has a grain of 1 day.
I am not sure if your
countriesData[0]
has a datetime column, so we'll use thealldates
array you passed togo.Scatter
:Then you can use your modified DataFrame to construct a candlestick chart: