我有一个两列数据帧,并打算将其转换为python字典 - 第一列将是键,第二列将是值.先感谢您.
数据帧:
id value
0 0 10.2
1 1 5.7
2 2 7.4
Run Code Online (Sandbox Code Playgroud) 我有数据框
ID A B C
0 p 1 3 2
1 q 4 3 2
2 r 4 0 9
Run Code Online (Sandbox Code Playgroud)
我想创建一个字典,其中 ID 是键,B 是值,所以它将是:
d["q"] = 3 , d["r"] = 0
这样做的最佳方法是什么?
它与假设的重复不同,因为我想要每个键的单个值而不是列表
我有2个不同的数据帧.第一个看起来像:
joint label x z y pt
0 1 NaN 50.4 0.0 -8.40 10
1 2 shell 52.2 0.0 -8.40 20
2 3 shell 54.0 0.0 -8.40 30
3 4 shell 55.8 0.0 -8.40 40
4 5 shell 57.6 0.0 -8.40 50
Run Code Online (Sandbox Code Playgroud)
我的第二个数据框看起来像:
member joint1 joint2 joint1_pt joint2_pt
0 1 1 2 0 0
1 2 2 3 0 0
2 3 3 4 0 0
3 4 4 5 0 0
Run Code Online (Sandbox Code Playgroud)
我想使用在特定连接上对应的pt值并在第二个数据帧上使用它,因此它将如下所示:
member joint1 joint2 joint1_pt joint2_pt …Run Code Online (Sandbox Code Playgroud)