首页 > 解决方案 > 使用 pandas pd.concat 后丢失的列

问题描述

我尝试使用以下代码组合两个数据框:

df1=pd.read_csv('NBA_2010_new.csv',encoding='ISO-8859-1')
df2=pd.read_csv('NBA_2011.csv',encoding='ISO-8859-1')
frames = [df1,df2]
combine = pd.concat(frames,axis=0,ignore_index=True,join='inner')
df=combine.reset_index(drop = True)
df.index += 1

CSV 文件最初包含 26 列..但是当我尝试使用 df.info() 查看 df 时...它只显示 22 列,有些列丢失了....

标签: pythonpandas

解决方案


推荐阅读