請您提供的零個數據一起工作的想法。根據你留下的一半線索,我完全猜測你的數據是什麼樣的。
df = pd.DataFrame(
{
'odor': np.random.choice(list('acflmnpsy'), 100),
'class': np.random.choice(list('ep'), 100),
'frequency': np.random.choice(np.arange(60, 241), 100)
}
)
df.groupby(['odor', 'class']).frequency.apply(np.array)
odor class
a e [170, 178, 67, 97]
p [183, 165, 73]
c e [106, 163, 71, 171]
p [72, 224, 112, 196, 134]
f e [134, 67, 190, 226, 74, 62, 107]
p [222, 74, 177, 186, 122, 120, 121]
l e [81, 97, 124, 181, 101, 185]
p [182, 136, 77, 190]
m e [217, 121, 141, 102, 171, 106]
p [127, 178, 127, 72, 209, 63, 167]
n e [166, 121, 79, 117, 130, 92]
p [71, 136, 219, 155]
p e [118, 193, 147, 219, 154, 130, 169]
p [69, 162, 138, 193, 236, 144, 192]
s e [105, 139, 143]
p [72, 149, 186, 220, 63]
y e [143, 134, 102, 144, 186, 207, 181]
p [177, 215, 190, 158, 203, 157, 85, 172]
Name: frequency, dtype: object