我需要帮助(“ str”和“ int”的实例之间不支持TypeError:“>”)

时间:2019-05-27 12:00:40

标签: python pandas typeerror loc

存在此类型错误,我绝对不知道如何解决。我是初学者,需要帮助

我凝视,清洗等等。什么都没做

df.loc[(df.Code=='RUS')&(df.Year>2015)]
TypeError                                 Traceback (most recent call last)
<ipython-input-42-d4d323e8dbe4> in <module>()
----> 1 df.loc[(df.Code=='RUS')&(df.Year>2015)]

/usr/local/lib/python3.6/dist-packages/pandas/core/ops.py in wrapper(self, other, axis)
   1764 
   1765             with np.errstate(all='ignore'):
-> 1766                 res = na_op(values, other)
   1767             if is_scalar(res):
   1768                 raise TypeError('Could not compare {typ} type with Series'

/usr/local/lib/python3.6/dist-packages/pandas/core/ops.py in na_op(x, y)
   1623 
   1624         if is_object_dtype(x.dtype):
-> 1625             result = _comp_method_OBJECT_ARRAY(op, x, y)
   1626 
   1627         elif is_datetimelike_v_numeric(x, y):

/usr/local/lib/python3.6/dist-packages/pandas/core/ops.py in _comp_method_OBJECT_ARRAY(op, x, y)
   1601         result = libops.vec_compare(x, y, op)
   1602     else:
-> 1603         result = libops.scalar_compare(x, y, op)
   1604     return result
   1605 

pandas/_libs/ops.pyx in pandas._libs.ops.scalar_compare()

TypeError: '>' not supported between instances of 'str' and 'int'

我只希望有一张表显示俄罗斯两年使用互联网的百分比。

0 个答案:

没有答案