• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to map correct values?

Resolved: How to map correct values?

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a dataframe where most of the values are wrongly mapped. here is my dataframe.
df:
I need to re-map every values to its correct column.
df_output:

Answer:

For fun, here is a hack way to perform the task (I really wouldn’t use this in real-life):
How it works:
  • 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!

regex
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Resolved: How to get Union type from an array of objects in Flow?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.