dingaro
dingaro

Reputation: 2342

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

enter image description here

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

enter image description here

And how can I combine these two tables so as to acheive DataFrame like below. It is not important what will be the index, simply I need to have table something like below.

enter image description here

Upvotes: 0

Views: 80

Answers (1)

BENY
BENY

Reputation: 323226

Let us just do

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

Upvotes: 1

Related Questions