Pandas groupby to find percent True and False

后端 未结 1 781
臣服心动
臣服心动 2020-12-10 16:17

I have a column of sites: [\'Canada\', \'USA\', \'China\' ....]

Each site occurs many times in the SITE column and next to each instance is a true or false value.

相关标签:
1条回答
  • Something like this:

    In [13]: g = df.groupby('SITE')['VALUE'].mean()
    In [14]: g[g > 0.1]
    Out[14]: 
    SITE
    Canada    0.5
    USA       1.0
    
    0 讨论(0)
提交回复
热议问题