AttributeError: 'numpy.ndarray' object has no attribute 'toList'
34,421
The method name is all lowercase: tolist
.
So you need to change the offending line to:
x.append(df.values.tolist())
Author by
Admin
Updated on August 19, 2021Comments
-
Admin over 2 years
I'm trying to append certain columns of
Pandas Data Frames
fromCSV
files into a numpy array. I have no idea how to instantiate an empty numpy array, so I'm testing it first with a list.def windows(files): x = [] for my_files in files: with open(os.path.join("/Users", "saqibali", "PycharmProjects", "sensorLogProject", "Data", my_files), 'rU') as my_file: df = pd.DataFrame(columns=['timestamp', 'time skipped', 'x', 'y', 'z', 'label']).set_index('timestamp') for d in sliding_window(sample_difference(my_file), 500, 250): df = df.append(d[['x', 'y', 'z']]) x.append(df.values.toList()) return x
I get the error in the title, and it doesn't make sense to me because
x
is alist
anddf
is aData Frame
.