【发布时间】:2017-12-03 11:41:44
【问题描述】:
我想重塑我的数据,使其显示 3 个维度。
这是创建虚拟数据的代码:
Sample = [{'account': 'Jones LLC', 'Jan': 150, 'Label': 0, 'Mar': [[.332, .326], [.058, .138]]},
{'account': 'Alpha Co', 'Jan': 200, 'Label': 0, 'Mar': [[.234, .246], [.013, .592]]},
{'account': 'Blue Inc', 'Jan': 50, 'Label': 1, 'Mar': [[.084, .23], [.745, .923]]}]
df = pd.DataFrame(Sample)
这是可视化的数据:
df:
account Jan Mar
Jones LLC | 150 | [[.332, .326], [.058, .138]]
Alpha Co | 200 | [[.234, .246], [.234, .395]]
Blue Inc | 50 | [[.084, .23], [.745, .923]]
现在如果我输入:
df['Mar'].shape
我得到 (3,)
如何更改此列,使其形状为 (3, 2, 2),以表示数组中的数据?
谢谢!!!
【问题讨论】:
标签: python arrays python-2.7 numpy keras