在python中将矩阵输出馈送到行输出

在python中将矩阵输出馈送到行输出,python,pandas,list,dataframe,metadata,Python,Pandas,List,Dataframe,Metadata,我有df1,看起来像这样,是特定日期商品的单价: Type 1/1/2019 2/1/2019 3/1/2019 Ac 20 25 30 Fan 10 20 15 Chair 5 10 10 以及另一

我有df1,看起来像这样,是特定日期商品的单价:

Type         1/1/2019           2/1/2019         3/1/2019
Ac              20                25               30
Fan             10                20               15
Chair           5                 10               10
以及另一个数据df2,其中包含出售的单位数量:

Date        Type       Ac        Fan      Chair
1/1/2019    AC, FAN    6         5         0
2/1/2019    Ac         4         0         0
3/1/2019    Chair,Fan  0         4         8
因此,我希望我的输出在列中也包括每单位价格,因此我的输出将如下所示:

Date        Type       Ac    Ac.Price     Fan    Fan.Price  Chair     chair.price
1/1/2019    AC, FAN    6       20          5        10         0         5
2/1/2019    Ac         4       25          0        20         0         10
3/1/2019    Chair,Fan  0       30          4        15         8         10
我尝试了
pd.concat([df1,df2]),axis=1)

但它不起作用,有人能帮我吗。谢谢…

我在这行master=PlanEffData.merge(new_Data,on='Date',后缀=(“”,“'u Price”)--验证合并键数据类型时出错。我们可能需要强制-@iamklausok尝试更新…df1是类型和日期作为标题的df…此外,如果错误持续存在,则您可能必须使用strftime将日期列的类型转换为字符串…您好@iamklaus,请帮助如何在当前代码中应用strftime。
new_df1 = df1.T.reset_index()

new_df1.columns = list(new_df1.loc[0])
new_df1 = new_df1.drop(index=[0]).rename({'Type':'Date'}, axis=1)

##new_df1

       Date  Ac Fan Chair
1  1/1/2019  20  10     5
2  2/1/2019  25  20    10
3  3/1/2019  30  15    10

master = df2.merge(new_df1, on='Date', suffixes=("","_Price"))
##print(master[['Date','Type','Ac','Ac_Price','Fan','Fan_Price','Chair','Chair_Price']])

       Date       Type  Ac Ac_Price  Fan Fan_Price  Chair Chair_Price
0  1/1/2019    AC, FAN   6       20    5        10      0           5
1  2/1/2019         Ac   4       25    0        20      0          10
2  3/1/2019  Chair,Fan   0       30    4        15      8          10