当前位置: 首页 > >

TypeError: '>=' not supported between instances of 'str' and 'float'

发布时间:

python错误记录1


TypeError: ‘>=’ not supported between instances of ‘str’ and ‘float’

代码片.


// An highlighted block
rating = pd.read_csv("D:/sweet/public data/data/ratings.csv",sep=",")
num_user = np.max(rating["userId"])
num_movie = np.max(rating["movieId"])
print(num_user,num_movie,len(rating))

修改

代码片.


// An highlighted block
rating = pd.read_csv("D:/sweet/public data/data/ratings.csv",sep=",")
num_user = np.max(rating["userId"].astype(str))
num_movie = np.max(rating["movieId"].astype(str))
print(num_user,num_movie,len(rating))

## 加上astype(str)




友情链接: