懵懂的菜鸟

Stay hungry,Stay foolish.

导航

文件读取ndarry 等价于DataFrame的操作

    LD=loadDatas()
    userMat=LD.makeRatingMatWithoutUserID()
    print(type(userMat))
    userRatingMat=pd.DataFrame(userMat,index=np.arange(1,944),columns=np.arange(1,1683))
    print(type(userRatingMat))

    userMat1=pd.read_csv('./data/userRatingTable.csv',header=None)
    userMat1.index=range(1,944)
    userMat1.columns=range(1,1683)
    print(type(userMat1))

    exit()

输出:

<class 'numpy.ndarray'>
<class 'pandas.core.frame.DataFrame'>
<class 'pandas.core.frame.DataFrame'>


  userRatingMat=pd.read_csv('./data/userRatingTable.csv',header=None)
  userRatingMat.index=range(1,944)
  userRatingMat.columns=range(1,1683)
  print(userRatingMat[4][10])#注意::这里前后颠倒了,表示矩阵中用户10对项目4的评分,即评分为4



 

posted on 2017-10-07 14:33  懵懂的菜鸟  阅读(524)  评论(0编辑  收藏  举报