我有一个数据帧(见下文),我想要遍历它来隔离某个数字(60)以上的值,并让它返回月份,我该怎么做:
Month Increase
0 Jan 34
1 Feb 4
2 Mar 33
3 Apr 12
4 May 66发布于 2016-06-09 00:40:06
IIUC您可以使用boolean indexing
mask = df.Increase > 60
print (mask)
0 False
1 False
2 False
3 False
4 True
Name: Increase, dtype: bool
print (df[mask])
Month Increase
4 May 66
print (df.loc[mask, 'Month'])
4 May
Name: Month, dtype: object发布于 2016-06-09 00:51:46
尝试使用过滤功能:
df[df['Increase']>60 ]
# Month Increase
#4 May 66
df[df['Increase']>60 ]['Month']
#4 May
#Name: Month, dtype: objecthttps://stackoverflow.com/questions/37708201
复制相似问题