这是文本中出现名称的数据框。名称“ Sage”,“ Davies”和“ Asplund”的出现时间相等。因此,我需要一个查询以返回所有三个名称。
Name,Occurrence
Sage,6
Davies,6
Asplund,6
Goodwin,5
Panula,5
Arnold,4
........
使用,获取行
In [1876]: df[df['Occurrence'] == df['Occurrence'].max()]
Out[1876]:
Name Occurrence
0 Sage 6
1 Davies 6
2 Asplund 6
而且,为了获得Name
小号
In [1878]: df.loc[df['Occurrence'] == df['Occurrence'].max(), 'Name']
Out[1878]:
0 Sage
1 Davies
2 Asplund
Name: Name, dtype: object
In [1879]: df.loc[df['Occurrence'] == df['Occurrence'].max(), 'Name'].values.tolist()
Out[1879]: ['Sage', 'Davies', 'Asplund']
并且,获得index
价值
In [1880]: df[df['Occurrence'] == df['Occurrence'].max()].index
Out[1880]: Int64Index([0, 1, 2], dtype='int64')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句