如何将序列直方图转换为绘图直方图?
我想绘制 timeDelta64 的直方图(示例:timeDelta('0天00:00:00:44.749500'
),
但在这两种情况下,Ploty.histogram()都不识别 (例如50t 60t(请参阅图像)
正确的时间显示值
fig = px.histogram(x=df_TT_redux["T_delta"],color=df_TT_redux["event_source"],log_y=True)
。 ”>
sstatic.net/hltwt.png“ rel =“ nofollow noreferrer 感谢LittlePanic404 转换为ISO格式可获得一些有趣的结果。我想我必须对此进行一些调整。
使用
import isodate
df_TT_redux["T_delta3"]=[isodate.duration_isoformat(x) for x in df_TT_redux["T_delta"]]
fig = px.histogram(x=df_TT_redux["T_delta3"],color=df_TT_redux["event_source"],color_discrete_map=color_discrete_map,log_y=False,log_x=False,nbins=100)
但是, 解决这个问题的另一种方法可能是:
df_TT_redux["T_delta2"]=df_TT_redux["T_delta"]/pd.Timedelta("1 hour")
或 .../pd.timedelta(“ 1分钟”)
。取决于您的情况
I want to plot histograms for timedelta64 (example: Timedelta('0 days 00:00:44.749500'
)
But in both cases, ploty.histogram() does not recognize the correct time but rather displays values (e.g., 50T 60T (See image)).
How do I have to convert the datetime/timedelta that plotly .histogram() recognizes the correct timeaxis? Thanks
fig = px.histogram(x=df_TT_redux["T_delta"],color=df_TT_redux["event_source"],log_y=True)
EDIT:
THanks to LittlePanic404
converting to ISO Format gives some interesting results. I guess I have to tweak that still a bit.
using
import isodate
df_TT_redux["T_delta3"]=[isodate.duration_isoformat(x) for x in df_TT_redux["T_delta"]]
fig = px.histogram(x=df_TT_redux["T_delta3"],color=df_TT_redux["event_source"],color_discrete_map=color_discrete_map,log_y=False,log_x=False,nbins=100)
However,
another way of solving this could be this:
df_TT_redux["T_delta2"]=df_TT_redux["T_delta"]/pd.Timedelta("1 hour")
or.../pd.Timedelta("1 minute")
. Depending on your case
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论