简体   繁体   English

如何在 Pandas Python 中组合两个数据帧?

[英]How can I combine two Data Frames in Pandas Python?

I have two DataFrames like below:我有两个数据帧,如下所示:

most_common_OMT = data["Order Method Type"].value_counts().sort_values(ascending=False).to_frame()
most_common_OMT

在此处输入图片说明

profitability_OMT = data.groupby("Order Method Type").agg({"Total Revenue":"mean"}).round(2).sort_values(by="Total Revenue",ascending=False)
profitability_OMT

在此处输入图片说明

And how can I combine these two tables so as to acheive DataFrame like below.以及如何组合这两个表以实现如下所示的 DataFrame。 It is not important what will be the index, simply I need to have table something like below.索引是什么并不重要,我只需要像下面这样的表。

在此处输入图片说明

让我们做

out = pd.concat([most_common_OMT, profitability_OMT], axis=1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM