我有一个当前看起来像这样的数据框,
我需要创建一个看起来像这样的数据框。
我需要从数据框1列中的值填充数据框2的列。该图显示了该示例。 此算法和过程应该是什么?
这是示例数据集
df_dict =
{'hostname': {0: 'Comp890263', 1: 'Comp813682', 2: 'Comp213302', 3: 'Comp839013', 4: 'Comp966241'},
'days': {0: 90, 1: 90, 2: 90, 3: 90, 4: 90},
'status': {0: '1', 1: '1', 2: '1', 3: '1', 4: '1'},
'features':
{0: '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0',
1: '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0',
2: '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0',
3: '0,0,0,0,0,0,0,21,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,0,0,0,0,0,0,0,0,0,6,46,0,0,0,0,759,0,0,0,0',
4: '0,0,0,0,0,0,0,43,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,0,0,0,0,0,0,0,0,0,30,46,0,0,0,0,795,0,0,0,0'}}
答案 0 :(得分:0)
这里有一个类似的问题:Pandas column values to columns?。看看他们的.pivot_table
或unstack
解决方案对您是否有用。