I have a df_1 like this:
A
apple, iphone, android
facebook, apple
macbook, laptop
firestick, hulu, netflix
android, laptop
laptop
And df_2 like this:
A B
apple 1
macbook 2
facebook 3
firestick 4
hulu 5
netflix 6
android 7
laptop 8
I am trying to extract a single word from A column of df_1 that has the lowest value in column B from df_2 like so:
A B_new
apple, iphone, android apple
facebook, apple apple
macbook, laptop macbook
hulu, netflix, firestick firesick
laptop, android android
laptop laptop
I assume I could sort each value of df_1 column A based on the values of B in df_2. Or create a function that takes in a single A value from df_1 and returns str with the smallest number in B from df_2. But as the data is quite big I assume using apply is not very efficient. Is there a neat Pandas way of doing such task?