close

[Solved] TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame”

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame” in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame” Error Occurs?

Today I get the following error TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame” in python.

How To Solve TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame” Error ?

  1. How To Solve TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame” Error ?

    To Solve TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame” Error The thing is dataframes to be concatenated need to be passed as list/tuple.

  2. TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame”

    To Solve TypeError: first argument must be an iterable of pandas objects, you passed an object of type “DataFrame” Error The thing is dataframes to be concatenated need to be passed as list/tuple.

Solution 1

IIUC you want the following:

df2 = pd.read_csv('et_users.csv', header=None, names=names2, chunksize=100000)
chunks=[]
for chunk in df2:
    chunk['ID'] = chunk.ID.map(rep.set_index('member_id')['panel_mm_id'])
    chunks.append(chunk)

df2 = pd.concat(chunks, ignore_index=True)

You need to append each chunk to a list and then use concat to concatenate them all, also I think the ignore_index may not be necessary but I may be wrong

Solution 2

Last line must be in following format:

df2=pd.concat([df1,df2,df3,df4,...], ignore_index=True)

The thing is dataframes to be concatenated need to be passed as list/tuple.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read