Roccochen7
V2EX  ›  问与答

关于 pandas 合并数据

  •  1
     
  •   Roccochen7 · May 18, 2019 · 1685 views
    This topic created in 2736 days ago, the information mentioned may be changed or developed.
    groupsize = pd.DataFrame(groupsize)
    print(type(groupsize))
    print(groupsize.head(1))
    

    <class 'pandas.core.frame.DataFrame'>

    Part No
    033G3802-6B-YH 2

    groupsum = pd.DataFrame(groupsum)
    print(type(groupsum))
    print(groupsum.head(1))
    

    <class 'pandas.core.frame.DataFrame'>

    Part No
    033G3802-6B-YH 7500.0

    rs = pd.merge(groupsize,groupsum,on = 'Part No')
    

    KeyError: 'Part No'

    怎么通过 Part No 把两个合并啊?

    Roccochen7
    Roccochen7
    OP
    May 18, 2019
    1
    rs = pd.concat([groupsize,groupsum],axis=1)
    可以了.....
    Oilybear
    Oilybear
    May 18, 2019
    2
    你要的是数据集 index 上的合并,不是 columns 上的合并兄弟,用 concat 的
    neosfung
    neosfung
    May 18, 2019 via iPhone
    3
    你是两列?
    不是 Part No
    而是 Part 吧?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1530 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:41 · PVG 00:41 · LAX 08:41 · JFK 11:41
    ♥ Do have faith in what you're doing.