如何使用散景在熊猫数据框中为每组绘制一条线

问题描述 投票:0回答:1

我将熊猫数据框分组为

                 registrationtime objecthandling  counts
0  2020-01-23 06:01:57.176000+00:00         Create       2
1  2020-01-23 06:01:57.176000+00:00         Delete       1
2  2020-01-23 06:01:57.176000+00:00   buildingUUID       1
3  2020-01-23 06:04:59.723000+00:00   buildingUUID       1
4  2020-01-23 06:07:37.707000+00:00   buildingUUID       1
5  2020-01-23 06:29:48.102000+00:00         Delete       2
6  2020-01-23 06:33:03.946000+00:00   buildingUUID       2
7  2020-01-23 06:34:15.447000+00:00   buildingUUID       1
8  2020-01-23 06:38:19.964000+00:00         Create       2
9  2020-01-23 06:38:19.964000+00:00         Delete       1
10 2020-01-23 06:41:17.589000+00:00         Create       1
11 2020-01-23 06:41:17.589000+00:00         Delete       2
12 2020-01-23 06:44:51.089000+00:00         Create       2
13 2020-01-23 06:44:51.089000+00:00         Delete       2
14 2020-01-23 06:44:51.089000+00:00       geometry       1

并且我想在Bokeh中绘制线条,其中x轴是datetime,因此列是[[registrationtime,而y轴是counts。但是,我需要根据<< objecthandling >>->列创建,删除,buildingUUID和几何图形的单独一行。在这种情况下,有四个不同的行到目前为止,我的代码

obj_handling_group = gdf.groupby(['registrationtime', 'objekthandling']).size().reset_index(name='counts') source = ColumnDataSource(obj_handling_group) p = figure(plot_height=350, plot_width=800, x_axis_type='datetime') p.line(x='registrationtime', y='counts', source=source, color='navy')

显然,这给了我一行,但是我如何根据

objecthandling
列中的值来分离数据?

我将熊猫数据框分组为注册时间对象处理计数0 2020-01-23 06:01:57.176000 + 00:00创建2 1 2020-01-23 06:01:57.176000 + 00:00 ...

python pandas bokeh
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.