Question:
I have a dataframe where most of the values are wrongly mapped. here is my dataframe.df:
df_output:
Answer:
For fun, here is a hack way to perform the task (I really wouldn’t use this in real-life):- convert as string
- if all letters -> 0
- if length > 2 -> 2
- else 1
- use the above number to sort the values and generate a new Series
- first field will be all letters, second 2 characters, third the longer string
output:
If you have better answer, please add a comment about this, thank you!