想把电影字符串类型的数据转化为python objectives
# Convert the stringified objects into the native python objects
from ast import literal_eval
features = ['cast', 'crew', 'keywords', 'genres']
for feature in features:
df[feature] = df[feature].apply(literal_eval)
试了.dropna()也不行
求解答,谢谢~
出现无法解析的错误,检查原数据是不是没有完整的标记结束符,比如字符串结尾是不是漏掉了}}等符号。
还可以试试用json.loads()来处理。
https://www.cnblogs.com/yoyoketang/p/9319829.html
是不是应该这么用
df[feature] = df[feature].apply(lambda x : literal_eval(x))