3 回答
TA贡献1744条经验 获得超4个赞
新增中 .T
df.values.T.tolist()
Out[465]:
[[-0.171321, 1.93377, 4.10144, 6.25064],
[0.0118587, 0.011752, 0.011296299999999999, 0.0103071],
[-0.148752, 1.9707, 4.06861, 5.83927]]
或者我们可以创建 dict
{x:df[x].tolist() for x in df.columns}
Out[489]:
{'Param_1': [-0.171321, 1.93377, 4.10144, 6.25064],
'Param_2': [0.0118587, 0.011752, 0.011296299999999999, 0.0103071],
'Param_3': [-0.148752, 1.9707, 4.06861, 5.83927]}
或使用locals(不推荐,但看起来像您所需要的)
variables = locals()
for key in df.columns:
variables["{0}".format(key)]= df[key].tolist()
Param_1
Out[501]: [-0.171321, 1.93377, 4.10144, 6.25064]
TA贡献1805条经验 获得超10个赞
也能 agg
>>> df.agg(tuple)
Param_1 (-0.171321, 1.93377, 4.10144, 6.25064)
Param_2 (0.0118587, 0.011752, 0.011296299999999999, 0....
Param_3 (-0.148752, 1.9707, 4.06861, 5.83927)
dtype: object
如果真的需要lists,
df.agg(tuple).transform(list)
添加回答
举报