我有一个“空”数据框,如下所示:
6807 6809 5341
126293 nan nan nan
126294 nan nan nan
126295 nan nan nan
列名给我一个name_id
,而索引值给我一个file_id
。现在我想在名为,的单独熊猫数据框中搜索file_id
和,它们看起来像这样:name_id
pro
cont
neutral
file_id name_id
0 126293 7244
1 126293 4978
2 126293 5112
3 126293 6864
如果我在数据框中找到file_id
和我想用 填充上面的空数据框单元格,当在 中找到时,在 中时,输入到矩阵中的值应该是。给我这样的结果,例如:name_id
pro
1
cont
-1
neutral
0
6807 6809 5341
126293 1 -1 0
126294 0 -1 0
126295 1 -1 1
有人知道如何完成这项工作吗?