Skip to content
Advertisement

Pandas: Sort dataframe correctly with German umlauts, upper/lowercase and numbers

I have this dataframe (all strings):

JavaScript

I want to sort it so that German umlauts are correct, also lowercase and numbers are correct:

JavaScript

Here is my code to generate the dataframe and result:

JavaScript

The result is almost correct, but the numbers are sorted in the wrong order, 20 should be before 200:

JavaScript

How can I fix the number sorting, while maintaining all the other characteristics?

Advertisement

Answer

Use solution from last sample data in DataFrame.sort_values:

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