pandas 合并series为dataframe

直接把series的list用pd.DataFrame()转换就可以了。

d
'''
[id_               AGENT0000000000
grid                           88
timestamp     2021-04-26 00:01:00
pos_x                     448.457
pos_y                     204.423
bearing                    4.1132
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                           48
timestamp     2021-04-26 00:02:00
pos_x                      415.22
pos_y                     127.278
bearing                   4.30558
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                            8
timestamp     2021-04-26 00:03:00
pos_x                     426.493
pos_y                     44.0383
bearing                     4.847
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                          -12
timestamp     2021-04-26 00:04:00
pos_x                      428.85
pos_y                    -39.9286
bearing                   4.74046
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                          -52
timestamp     2021-04-26 00:05:00
pos_x                     428.115
pos_y                    -123.925
bearing                   4.70363
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                          -92
timestamp     2021-04-26 00:06:00
pos_x                     410.275
pos_y                    -206.009
bearing                   4.49838
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                         -113
timestamp     2021-04-26 00:07:00
pos_x                     397.043
pos_y                     -288.96
bearing                   4.55421
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                         -153
timestamp     2021-04-26 00:08:00
pos_x                      380.11
pos_y                    -371.236
bearing                   4.50941
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                         -193
timestamp     2021-04-26 00:09:00
pos_x                     390.828
pos_y                    -454.549
bearing                   4.84034
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object, id_               AGENT0000000000
grid                         -212
timestamp     2021-04-26 00:10:00
pos_x                     428.143
pos_y                    -529.806
bearing                   5.17269
category                  WALKING
speed_rank                      1
speed                         1.4
dtype: object]
'''
df = pd.DataFrame(d)
'''

id_	grid	timestamp	pos_x	pos_y	bearing	category	speed_rank	speed
0	AGENT0000000000	88	2021-04-26 00:01:00	448.456657	204.423017	4.113199	WALKING	1	1.4
1	AGENT0000000000	48	2021-04-26 00:02:00	415.219566	127.278375	4.305581	WALKING	1	1.4
2	AGENT0000000000	8	2021-04-26 00:03:00	426.492871	44.038285	4.847001	WALKING	1	1.4
3	AGENT0000000000	-12	2021-04-26 00:04:00	428.850296	-39.928628	4.740457	WALKING	1	1.4
4	AGENT0000000000	-52	2021-04-26 00:05:00	428.114793	-123.925408	4.703633	WALKING	1	1.4
5	AGENT0000000000	-92	2021-04-26 00:06:00	410.274789	-206.009111	4.498378	WALKING	1	1.4
6	AGENT0000000000	-113	2021-04-26 00:07:00	397.043201	-288.960453	4.554211	WALKING	1	1.4
7	AGENT0000000000	-153	2021-04-26 00:08:00	380.109717	-371.235948	4.509409	WALKING	1	1.4
8	AGENT0000000000	-193	2021-04-26 00:09:00	390.828151	-454.549303	4.840338	WALKING	1	1.4
9	AGENT0000000000	-212	2021-04-26 00:10:00	428.142720	-529.806349	5.172694	WALKING	1	1.4
'''

你可能感兴趣的:(Python学习杂货铺)