以下是以下命令的输出-
df['x'].value_counts() -1 266551 1 172667 0 155994
我想计算除值-1之外的所有计数的最大值。
在这种情况下,答案将是172667。
如何从其中删除-1的值并选择其他值的最大值?
发布于 2017-10-12 14:22:33
使用drop + max
drop
max
df['x'].value_counts().drop(-1).max()
示例:
s = pd.Series([266551,172667,155994], index=[-1,1,0]) print (s) -1 266551 1 172667 0 155994 dtype: int64 print (s.drop(-1).max()) 172667
https://stackoverflow.com/questions/46702755
相似问题