Pandas 熊猫'&燃气轮机';在';str';和';int';
我想删除符合以下两个条件的所有行:Pandas 熊猫'&燃气轮机';在';str';和';int';,pandas,Pandas,我想删除符合以下两个条件的所有行: df = df.drop(df[(df['home'] == 'away') &(df['ranking'] > 12)].index) 但这是一个错误: TypeError: '>' not supported between instances of 'str' and 'int' 如何修复此问题?让我们试试 df['ranking'] = pd.to_numeric(df['ranking'],errors
df = df.drop(df[(df['home'] == 'away')
&(df['ranking'] > 12)].index)
但这是一个错误:
TypeError: '>' not supported between instances of 'str' and 'int'
如何修复此问题?让我们试试
df['ranking'] = pd.to_numeric(df['ranking'],errors='coerce')
df排名列类型是字符串?它被刮为文本..所以可能,是的。在检查之前,如何将值强制为数字?