dimanche 7 juin 2020

How to use if loop function to shift the categorical column from number into character? [duplicate]

I have a dataset called df like this (sorry it's a big data so I can't share the code creating the dataset): enter image description here

In the region column I have four categories, 1, 2, 3 and 4. How can I use if loop function to change the number into character that each number represents? (1: northeast, 2: midwest, 3: south, 4: west)

Thanks many!

Aucun commentaire:

Enregistrer un commentaire