TypeError:第一个参数必须是熊猫对象的可迭代对象,您传递了“ DataFrame”类型的对象

问题描述

IIUC您需要以下内容

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)

您需要将每个块附加到列表中,然后用于concat将它们全部串联起来,我也认为ignore_index可能没有必要,但是我可能错了

解决方法

我有一个大数据框,然后尝试将其拆分concat。我用

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

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

但它返回一个错误

TypeError: first argument must be an iterable of pandas objects,you passed an object of type "DataFrame"

我该如何解决?