The content saved in Excel with such a key value mapping is as follows
key1key2 key3valueav1abv2abcv3If 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 key3valueabcv3abv2av1Then 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