gpt4 book ai didi

python - Pandas 在索引列上合并?

转载 作者:太空狗 更新时间:2023-10-30 01:47:45 25 4
gpt4 key购买 nike

<分区>

In [88]: c
Out[88]:
Address Name
CustomerID
10 Address for Mike Mike
11 Address for Marcia Marcia

In [89]: c.index
Out[89]: Int64Index([10, 11], dtype='int64', name='CustomerID')

In [90]: orders
Out[90]:
CustomerID OrderDate
0 10 2014-12-01
1 11 2014-12-01
2 10 2014-12-01

In [91]: orders.index
Out[91]: RangeIndex(start=0, stop=3, step=1)

In [92]: c.merge(orders)
---------------------------
MergeError: No common columns to perform merge on

因此,如果一个 dataframe 中的 index 列与第二个 dataframe 中的另一列同名,panda 将无法合并?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com