Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 'list' object has no attribute 'reshape'
Hi All,

I've just joined this forum, also new to Python, with background in other languages.

I've been trying a small piece of code below using jupyter ipython in, the error is coming from the last call for np.reshape function which I'd used it previously with no problems, so your comment/tips would be much appreciated, many thanks:

import numpy as np
import pandas as pd

file = open("/home/nbuser/F-F_Research_Data_Factors_StrippedandCleaned.txt","r")
data = file.readlines()


for i in range(1,np.size(data)):
    t= data[i].split()
    for j in range(1,5):
and get the below:

Attribute Error: 'list' object has no attribute 'reshape'
np.reshape ultimately calls up the reshape method of the object passed to it. So, it's trying to call list.reshape() which doesn't exist. The documentation suggests that it needs an array instead of a list to effectively work.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Simple numpy reshape error wih contour3D AdeIsHere 0 111 Sep-17-2019, 12:01 PM
Last Post: AdeIsHere
  Pandas to_csv in for loop AttributeError: 'tuple' object has no attribute 'to_csv' NSearch 9 2,164 Apr-22-2019, 05:05 PM
Last Post: Yoriz
  AttributeError: 'NoneType' object has no attribute 'all' synthex 2 748 Mar-07-2019, 11:11 AM
Last Post: synthex
  Please help with AttributeError: 'Netz' object has no attribute 'conv' DerBerliner 2 489 Feb-27-2019, 06:01 PM
Last Post: DerBerliner
  Generating a list to feed into a class object zizi 0 465 Nov-02-2018, 01:50 PM
Last Post: zizi
  AttributeError: 'set' object has no attribute 'items hey_arnold 3 9,291 Apr-29-2018, 04:33 PM
Last Post: hey_arnold

Forum Jump:

Users browsing this thread: 1 Guest(s)