我创建了一个字典d
,其中A
是一个包含class
class Driver(object):
def __init__(self, name, raw_value, Id1):
self.name = name
self.raw = raw_value
self.Indicator1 = Id1
d = {}
for i in range(0,len(A)):
if not A[i].name in d:
d[A[i].name] = [A[i].Indicator1]
else:
d[A[i].name] += [A[i].Indicator1]
所以
d[driver[0]] =
[0 0.002862
1 -15.005252
2 0.009653
3 -15.192950
4 14.941727
5 44.977511
Name: 3, dtype: float64,
0 0.005229
1 -0.230766
2 14.803119
3 -0.005263
Name: 3, dtype: float64,
0 -3.756292
1 14.827995
2 45.595015
3 44.964029
4 14.820670
Name: 3, dtype: float64]
如我notebook
我希望只获取其中的值,所以:
v = [0.002862, -15.005252, 0.009653,-15.192950, 14.941727, ..., 44.964029, 4.820670]
答案 0 :(得分:1)
试试这个:
import pandas as pd
pd.concat(d[users[0]]).values
这会将您的pandas系列(或numpy数组)列表连接成一个,然后您可以应用values
访问器以获取numpy数组或.tolist()
函数以获取常规的Python列表