panda读取数据

读取csv文件(movie数据集)

import pandas as pd
df_rating = pd.DataFrame(pd.read_csv('ratings.csv'))
for index, row in df_rating.iterrows():
    userId = row["userId"]
    movieId = row["movieId"]
    rating = row["rating"]
    movieId = movieId.astype(int)  # float64 to int
    userId = userId.astype(int)
    print(movieId, '\t', rating, '\t', userId)
posted @ 2020-12-23 14:08  _一只土拨鼠  阅读(111)  评论(0)    收藏  举报