Skip to content
Advertisement

TypeError: cannot concatenate object of type ”; only Series and DataFrame objs are valid

I have a list of 10 dataframes named d0, d1, d2,…d9. All have 3 columns and 100 rows.

JavaScript

I want to merge all dataframes so that I can have 3 columns and 1000 rows and then convert it into an array.

JavaScript

The above code throws error:

JavaScript

I used the solution suggested in pd.concat in pandas is giving a TypeError: cannot concatenate object of type ‘<class ‘str’>’; only Series and DataFrame objs are valid ; however, got the above error.

Advertisement

Answer

s1 is already a list. Doing what you did called pd.concat with a list of a list with DataFrames, which pandas doesn’t allow. You should do it like this instead:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement