Python 基于std的滤波器多指标测向
通过以上步骤,我得到了以下多指标df:Python 基于std的滤波器多指标测向,python,pandas,multi-index,Python,Pandas,Multi Index,通过以上步骤,我得到了以下多指标df: df.groupby(['name','cat'])['valtocount'].agg('count') 我只想保留计数标准大于0的名称 你们有什么建议吗?与std一起使用或通过以下方式进行过滤: name cat count abc a 1 b 1 def a 1 c 2 s = df.groupby(['name','cat'])['valtocount'].agg('count') s1 = s[s.g
df.groupby(['name','cat'])['valtocount'].agg('count')
我只想保留计数标准大于0的名称
你们有什么建议吗?与std一起使用或通过以下方式进行过滤:
name cat count
abc a 1
b 1
def a 1
c 2
s = df.groupby(['name','cat'])['valtocount'].agg('count')
s1 = s[s.groupby(level=0).transform('std') > 0]
print (s1)
name cat
def a 1
c 2
Name: valtocount, dtype: int64
s1 = s[s.groupby(level=0).transform('nunique') != 1]