Python Forum
'list' object has no attribute 'reshape'
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.

Possibly Related Threads…
Thread Author Replies Views Last Post
  [pandas] How to reshape the list Mekala 6 949 Jul-26-2020, 12:49 AM
Last Post: Mekala
  cannot reshape array of size 0 into shape Roro 2 2,240 Jun-14-2020, 11:28 AM
Last Post: Roro
  reshape from 3D to 3D matrix paul18fr 0 552 Nov-12-2019, 11:26 AM
Last Post: paul18fr
  Simple numpy reshape error wih contour3D AdeIsHere 0 684 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 7,944 Apr-22-2019, 05:05 PM
Last Post: Yoriz
  AttributeError: 'NoneType' object has no attribute 'all' synthex 2 2,200 Mar-07-2019, 11:11 AM
Last Post: synthex
  Please help with AttributeError: 'Netz' object has no attribute 'conv' DerBerliner 2 1,542 Feb-27-2019, 06:01 PM
Last Post: DerBerliner
  Generating a list to feed into a class object zizi 0 1,054 Nov-02-2018, 01:50 PM
Last Post: zizi
  AttributeError: 'set' object has no attribute 'items hey_arnold 3 17,457 Apr-29-2018, 04:33 PM
Last Post: hey_arnold

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020