why numpy.ndarray is object is not callable in my simple for python loop

前端 未结 4 920
我寻月下人不归
我寻月下人不归 2020-12-08 22:41

I loaded a text file containing a two column matrix (e.g. below)

[ 1   3
  2   4
  3   5 
  2   0]

My calculation is just to sum each row

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 23:17

    Avoid the for loopfor XY in xy: Instead read up how the numpy arrays are indexed and handled.

    Numpy Indexing

    Also try and avoid .txt files if you are dealing with matrices. Try to use .csv or .npy files, and use Pandas dataframework to load them just for clarity.

提交回复
热议问题