Python Pandas分组操作中出现unsupported operand type(s) for -: 'NoneType' and 'int'错误
有没有人见过或者理解我在使用pandas进行值计数操作时遇到的错误?我检查过这个列,里面只有用字符串表示的数字。我想弄清楚是什么导致了这个问题;这是我第一次见到这样的情况。
col1
3234
2334
4342
...
df[col1].value_counts()
返回了
<repr(<pandas.core.series.Series at 0x819a0d0>) failed: TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'>
1 个回答
0
这似乎和我设置的 display.max_rows 有关,我把它设置成了“None”。当我把它改回默认的60时,我就可以在这个列上进行分组操作了。