我正在使用neo4j图形数据库编写一个简单的推荐系统。我使用py2neo lib,这是我的程序:
...
for m,row in movie.iterrows() :
tx.run(statement1, {"A": row.loc['id'], "B": row.loc['title'], "C": row.loc['IMDb url']})
is_genre = row.iloc[-19:]==1
related_genres = genre[is_genre].axes[0].values
for g in related_genres :
tx.run(statement2, {"A": row.loc['id'], "B": row.loc['title'], "C": row.loc['IMDb url'], "D": g})
if m%100==0 : tx.process()
tx.commit()
然后,发生错误:
Traceback (most recent call last):
File "c:\Users\quy.lv\Desktop\He_thong_goi_y\He_thong_goi_y_phim.py", line 48, in <module>
tx.run(statement2, {"A": row.loc['id'], "B": row.loc['title'], "C": row.loc['IMDb url'], "D": g})
...
TypeError: Neo4j does not support PackStream parameters of type int64
似乎发生在该行中:
tx.run(statement2, {"A": row.loc['id'], "B": row.loc['title'], "C": row.loc['IMDb url'], "D": g})
任何人都可以帮助我修复它。谢谢!
答案 0 :(得分:0)
我通过添加int()将np.int64类型转换为int类型来解决它,例如:
tx.run(statement1, {"A": int(row.loc['id']), "B": row.loc['title'], "C": row.loc['IMDb url']})