我正在寻找将[0,0]数组添加到' Mar'如果形状小于(3,)
,则为列示例数据框可视化:
df:
account Jan Feb Mar
Jones LLC | 150 | 200 | [.332, .326], [.058, .138]
Alpha Co | 200 | 210 | [[.234, .246], [.234, .395], [.013, .592]]
Blue Inc | 50 | 90 | [[.084, .23], [.745, .923]]
再次:我正在寻找将[0,0]数组添加到' Mar'列,以便修改形状小于(3,x)的任何行,导致以下df
df:
account Jan Feb Mar
Jones LLC | 150 | 200 | [.332, .326], [.058, .138], [0, 0]
Alpha Co | 200 | 210 | [[.234, .246], [.234, .395],[.013, .592]
Blue Inc | 50 | 90 | [[.084, .23], [.745, .923], [0, 0]
创建示例数据帧的代码:
Sample = [{'account': 'Jones LLC', 'Jan': 150, 'Feb': 200, 'Mar': [[.332, .326], [.058, .138]]},
{'account': 'Alpha Co', 'Jan': 200, 'Feb': 210, 'Mar': [[.234, .246], [.234, .395], [.013, .592]]},
{'account': 'Blue Inc', 'Jan': 50, 'Feb': 90, 'Mar': [[.084, .23], [.745, .923]]}]
df = pd.DataFrame(Sample)