V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Roccochen7
V2EX  ›  问与答

关于 pandas 合并数据

  •  1
     
  •   Roccochen7 · May 18, 2019 · 1354 views
    This topic created in 2549 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
        1
    Roccochen7  
    OP
       May 18, 2019
    rs = pd.concat([groupsize,groupsum],axis=1)
    可以了.....
    Oilybear
        2
    Oilybear  
       May 18, 2019
    你要的是数据集 index 上的合并,不是 columns 上的合并兄弟,用 concat 的
    neosfung
        3
    neosfung  
       May 18, 2019 via iPhone
    你是两列?
    不是 Part No
    而是 Part 吧?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1090 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 93ms · UTC 23:15 · PVG 07:15 · LAX 16:15 · JFK 19:15
    ♥ Do have faith in what you're doing.