熊猫映射数据框列

时间:2019-10-30 13:25:01

标签: python pandas dataframe

我的输入数据框如下:

Store  PG1       PG2              PG3                      PG4
500    1 Women   02 Shirts        02 S-S_Woven_Shirts      02 Checked-Striped-
552    2 Baby
600    4 Boys    00 Denim All
704    5 Girls   01 Jackets       15 Woven blouses, tops


Store      MinThreshold   MaxThreshold   PG1       PG2               PG3                      PG4   
552        0              10             2 Baby
552        2              15             2 Baby    00 Denim All
600        3              16             5 Girls
600        4              17             4 Boys    00 Denim All
704        5              18             5 Girls   01 Jackets        15 Woven blouses, tops
704        10             20             0 Men     00 Denim_Bottoms  02 Capris   
500        6              19             1 Women   02 Shirts         02 S-S_Woven_Shirts      02 Checked-Striped-Patterned_Shirts-Tops-Blouses

所需的输出为;

Store  PG1      PG2             PG3                   PG4                 MinThreshold  MaxThreshold                    
500    1 Women  02 Shirts       02 S-S_Woven_Shirts   02 Checked-Striped- 6             19
552    2 Baby                                                             2             15
600    4 Boys   00 Denim All                                              4             17
704    5 Girls  01 Jackets      15 Woven blouses, tops                    5             18

我想基于“存储”,“ PG1”,“ PG2”,“ PG3”和“ PG4”将阈值从第二数据帧添加到第一数据帧。

我尝试过了

df1 = pd.merge(df1, df2,  how='left',
 left_on=["Store","PG1","PG2","PG3","PG4"], right_on =["Store","PG1","PG2","PG3","PG4"])

您能帮我吗?

0 个答案:

没有答案