![](/img/trans.png)
[英]Sort a Pandas Data Frame based on group by some operation on another column
[英]Sort a column based on the sorting of a column from another pandas data frame
我有這樣的數據幀:
df1:
col1 col2
P 1
Q 3
M 2
我有另一個數據幀:
df2:
col1 col2
Q 1
M 3
P 9
我想根據df1的col1順序對df2的col1進行排序。 所以最終的數據框將如下所示:
df3:
col1 col2
P 1
Q 3
M 9
如何使用熊貓或任何其他有效的方法?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.