我有以下的DataFrame
,其中Track ID
是行索引。如何将stats
列中的字符串拆分成5列数字?
Track ID stats
14.0 (-0.00924175824176, 0.41, -0.742016492568, 0.0036830094242, 0.00251748449963)
28.0 (0.0411538461538, 0.318230769231, 0.758717081514, 0.00264000622468, 0.0106535783677)
42.0 (-0.0144351648352, 0.168438461538, -0.80870348637, 0.000816872566404, 0.00316572586742)
56.0 (0.0343461538462, 0.288730769231, 0.950844962874, 6.1608706775e-07, 0.00337262030771)
70.0 (0.00905164835165, 0.151030769231, 0.670257006716, 0.0121790506745, 0.00302182567957)
84.0 (-0.0047967032967, 0.171615384615, -0.552879463981, 0.0500316517755, 0.00217970256969)
df.to_dict()
,但它向我展示了我的数据中的stats
列确实是元组,而不是字符串。例如,使用[float(x[0]) for x in df['stats']]
给了我第0个元素。 - t_n