Skip to content
Advertisement

Return row from a dataframe according to a list of priority values to search

I have a list of values in a sequence from most important to least important, if it doesn’t find a value, it searches for the next one and so on:

JavaScript

Is there a more professional way to the same result or is this the correct model?

Advertisement

Answer

A possible solution involves turning your ‘market_name’ column into categorical as explained in this answer: Custom sorting in pandas dataframe

In your case this would do the trick:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement