Recoding Categorical to Numerical
John Griner
johndavidgriner74 at gmail.com
Fri Aug 13 18:33:22 EDT 2021
Hello, and thanks in advance,
I am trying to recode categorical variable to numeric. Despite using
lambda, If else, dummy-recoding, and so forth, what I get is from ONE
column that has 4 variables (City, Town, Suburb, Rural), I get FOUR columns:
localeDummy_City localeDummy_Town localeDummy_Suburb
localeDummy_Rural locale_recode
with the corresponding numeric variable.
What I want is the recode to have ONE column that has the numeric
conversion.
For instance:
local_recode
2
4
4
6
2
8
6
2
8
2
2
4
6
4
8
and so forth, where I have set City to 2, and Town to 4, etc.
Again, thanks, John
loca
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
More information about the Python-list
mailing list