程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

pandas dataframe sorting

編輯:Python

The content saved in Excel with such a key value mapping is as follows

key1key2 key3valueav1abv2abcv3

If the text contains a b c, mark it with v3 tag, if it contains a b, mark it with v2 tag, if it only contains a, mark it with v1 tag

Read this Excel that saves this mapping relationship into Pandas how to do this sort

That is, key1, key2, and key3 are not empty in the first row, followed by one empty, and finally two empty

That is, after the above table is sorted, it becomes

key1key2 key3valueabcv3abv2av1

Then follow this order to match one by one, hit the previous one, and the latter will no longer match. For example, if it matches a b c, it will no longer match a b and match a. The tag corresponding to the text is v3

Q: How to sort Pandas dataframe like this



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved