Python 3.7.6.
I'm trying to add data frames to the list, but it doesn't work because it's judged to be str type.
The results are as follows:
files is a list that contains the file path to be read by the func function.
lst=list()
for i in files:
lst.append(func(k=files[i]))
TypeError: list indications must be integrators or slices, not str
Looking for str, it looks like a data frame.
In[10]—type(func(k=files[i]))
Out [10]—pandas.core.frame.DataFrame
Is it impossible to append the data frame to the list?
I would appreciate it if you could reply to me if you know more.
Thank you for your cooperation.
python pandas
Why don't you make it into a two-dimensional array?
For example, the dataframe name is name_df.
First, retrieve the dataframe column.
files=list(name_df.columns)
Then use the columns to store dataaframe elements in the array.
lis=[ ]
for w, i in enumerate (files):
lis.append([])
lis[w].append(name_df[i])
Can I do what I want with this?
I don't really understand what I want to do, so it may be a vague answer.
Try it
366 To Limit Column Values to Strings in a String List Using sqlalchemy
356 Unity Virtual Stick Does Not Return to Center When You Release Your Finger
340 Memory layouts learned in theory don't work out as expected when actually printed as addresses.
371 Update Flask User Information
353 I have saved several codes written in python to a visual studio file.
© 2023 OneMinuteCode. All rights reserved.