Inserting a row in pandas by searching and using an order priority

Solution 1:

It will have been more helpful if you told us how the new lists occur. Anyway, I assume you get a list at a time. If thats the case, combine the lists into one.

Once you have combined, bring the corresponfind elements into a new list. Map each list in the new list of lists onto existing columns. Generate a new dataframe. Append this dataframe to the existing. Sort the resulting by Priority. Code below

l1=['2021-Priority-1-Josh', 20]
l2=['2021-Priority-1-Jimmy', 21]

lis=[l1,l2]

df.append(pd.DataFrame(dict(zip(df.columns,[list(x) for x in zip(*lis)])))).sort_values(by='Priority', ascending=False)

Outcome

     EventNo-Name      Priority
1  2021-Priority-1-Jimmy        21
0   2021-Priority-1-Josh        20
0      2021-Normal-1-Joe        18
1     2021-Normal-2-Jack        17
2     2021-Normal-3-John        16
3    2021-Normal-4-James        15
4      2021-Normal-5-Jim        14

How it works

# Combine like elements in the two lists

l1=[list(x) for x in zip(*lis)]

#Generate a dataframe constructor

d1 =dict(zip(df.columns,l1)) #

#Generate a dataframe 

df1 =pd.DataFrame(d1)

#append to old Dataframe

df.append(df1).sort_values(by='Priority', ascending=False)