无法连接 pandas 个具有相同长度的数据帧?

Can't concatenate pandas dataframes with the same length?

这很奇怪。从文档中,我已经准备好阅读如何使用 concat 和合并操作 pandas。我也都知道可以按如下方式连接到右侧:

df = pd.concat([df1, df2], axis=1)

问题是我生成了以下数据帧:

在:

links = pd.DataFrame(links, columns=['link'])

所以,我只想将 link 数据帧列连接到 intersection 数据帧(注意 linkintersection 有 78 个长度实例)。因此:

在:

full_table = pd.concat([lis_, lis_2], axis=1)

问题是,正如您在上面的数据框中看到的,它添加了一些 NaN 值。因此,连接 linksintersection 数据帧的正确方法是什么?

也许您的索引不匹配。尝试使用 ignore_index 参数:

full_table = pd.concat([intersection, links], axis=1, ignore_index=True)