Pandas DataFrame sort ignoring the case
Pandas 1.1.0 introduced the key
argument as a more intuitive way to achieve this:
df.sort_values(by='Single', inplace=True, key=lambda col: col.str.lower())
You can convert all strings to upper/lower case and then call argsort()
which gives the index value to reorder the data frame by Single ignoring the case:
df.iloc[df.Single.str.lower().argsort()]