如果条件在pandas dataframe中

时间:2016-06-09 14:44:29

标签: python pandas dataframe

我检查df4中是否有任何符合条件的行。 但它会引发错误"指数超出范围"。任何帮助将不胜感激。

if (df4[df4['Occurences']] >= 5).any():
 df7 = df4[df4['Occurences'] >= 5].reset_index()
 df8 = df7[['MachineName','DateTime','Occurences']]
 rpt = dataframeToHtmlTable(df8)    
 sendNotificationAlive(rpt, ['sridevibaskaran@geotab.com'])

1 个答案:

答案 0 :(得分:3)

你的第一行:

if (df4[df4['Occurences']] >= 5).any():

看起来不对,关闭的方括号应该包括条件:

if (df4[df4['Occurences'] >= 5]).any():