如何将序列直方图转换为绘图直方图?

发布于 2025-02-09 20:01:27 字数 1236 浏览 4 评论 0原文

我想绘制 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)

enter image description here

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)

enter image description here

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

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文