熊猫合并仅返回空值

时间:2018-11-01 17:32:46

标签: python pandas merge

我正在尝试使用Pandas将产品包装信息与给定产品的每个订单记录合并。数据帧信息如下。

     BreakerOrders.info()
   <class 'pandas.core.frame.DataFrame'>
    Int64Index: 3774010 entries, 0 to 3774009
    Data columns (total 2 columns):
    Material    object
    Quantity    float64
    dtypes: float64(1), object(1)
    memory usage: 86.4+ MB

     manh.info()
   <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 1381 entries, 0 to 1380
    Data columns (total 4 columns):
    Material       1381 non-null object
    SUBPACK_QTY    202 non-null float64
    PACK_QTY       591 non-null float64
    PALLET_QTY     809 non-null float64
    dtypes: float64(3), object(1)
    memory usage: 43.2+ KB

使用下面的代码尝试合并时,我得到了下表,其中包含包装数量的所有NaN值。

   BreakerOrders.merge(manh,how='left',on='Material')


    Material    Quantity    SUBPACK_QTY   PACK_QTY  PALLET_QTY
    HOM230CP    5.0             NaN         NaN        NaN
    QO115       20.0            NaN         NaN        NaN
    QO2020CP    20.0            NaN         NaN        NaN
    QO220CP     50.0            NaN         NaN        NaN
    HOM115CP    50.0            NaN         NaN        NaN
    HOM120      100.0           NaN         NaN        NaN

0 个答案:

没有答案