在熊猫数据框图中获取当前的组名称

发布于 2025-02-09 16:24:36 字数 734 浏览 0 评论 0原文

有这样的数据

                       Timestamp Function_code  Node_id  Delta
0     2000-01-01 10:39:51.790683      Tx_PDO_2       54  551.0
1     2000-01-01 10:39:51.791650      Tx_PDO_2       54  601.0
2     2000-01-01 10:39:51.792564      Tx_PDO_3       54  545.0
3     2000-01-01 10:39:51.793511      Tx_PDO_3       54  564.0 

框Windows,X轴上的Timestamp的图形,delta在y轴上。一个用于tx_pdo_2,另一个用于tx_pdo_3

delta_rx_tx_df.groupby("Function_code").plot(x="Timestamp", y="Delta", )

现在,我想知道哪个窗口对应于哪个function_code_code

我尝试使用title = delta_rx_tx_df.groupby(“ function_code”)。组,但它不起作用。

I have a data frame like that (it's just the head) :

                       Timestamp Function_code  Node_id  Delta
0     2000-01-01 10:39:51.790683      Tx_PDO_2       54  551.0
1     2000-01-01 10:39:51.791650      Tx_PDO_2       54  601.0
2     2000-01-01 10:39:51.792564      Tx_PDO_3       54  545.0
3     2000-01-01 10:39:51.793511      Tx_PDO_3       54  564.0 

There are only two types of Function_code : Tx_PDO_2 and Tx_PDO_3

I plot in two windows, a graph with Timestamp on the x-axis and Delta on the y-axis. One for Tx_PDO_2 and the other for Tx_PDO_3 :

delta_rx_tx_df.groupby("Function_code").plot(x="Timestamp", y="Delta", )

Now, I want to know which window corresponds to which Function_code

I tried to use title=delta_rx_tx_df.groupby("Function_code").groups but it did not work.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若相惜即相离 2025-02-16 16:24:37

可能有一种更好的方法,但是对于初学者来说,您可以在创建它们后将标题分配给图:

plots = delta_rx_tx_df.groupby("Function_code").plot(x="Timestamp", y="Delta")
plots.reset_index()\
     .apply(lambda x: x[0].set_title(x['Function_code']), axis=1)

There may be a better way, but for starters, you can assign the titles to the plots after they are created:

plots = delta_rx_tx_df.groupby("Function_code").plot(x="Timestamp", y="Delta")
plots.reset_index()\
     .apply(lambda x: x[0].set_title(x['Function_code']), axis=1)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文