这是数据框
movie_df["year"] 列是从标题列中提取值创建的:
movie_df["year"] = movie_df["title"].str.extract("(\d+)")
代码行
错误
答案 0 :(得分:0)
在python中int
是一个将字符串转换为整数的函数。因此,当您传递它时,您实际上是在传递错误描述的方法。从 pandas 的文档来看,它看起来像 .astype
需要一个字符串作为参数。例如:
movie_df["year"].astype("int32")
文档:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.astype.html