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
710 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
549 PHP ssh2_scp_send fails to send files as intended
542 Unable to install versioned in Google Colab
537 Uncaught (inpromise) Error on Electron: An object could not be cloned
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.