I want to change the value of column "MSSubClass" and "MoSold"in my dataframe "trainData" using replace method:
"MSSubClass": change all numerical value like 20 to "SC20", 30 : "SC30", 40 : "SC40", 45 : "SC45", 50 : "SC50", ...
"MoSold": change all numerical value to month, like 1 to "Jan", 2 : "Feb", 3 : "Mar", 4 : "Apr", 5 : "May", 6 : "Jun", ...
I have tried the straight forward way as followed:
trainData['MSSubClass'].replace({20 : "SC20", 30 : "SC30", 40 : "SC40", 45 : "SC45", 50 : "SC50", 60 : "SC60", 70 : "SC70", 75 : "SC75", 80 : "SC80", 85 : "SC85", 90 : "SC90", 120 : "SC120", 150 : "SC150", 160 : "SC160", 180 : "SC180", 190 : "SC190"})
trainData['MoSold'].replace({1 : "Jan", 2 : "Feb", 3 : "Mar", 4 : "Apr", 5 : "May", 6 : "Jun", 7 : "Jul", 8 : "Aug", 9 : "Sep", 10 : "Oct", 11 : "Nov", 12 : "Dec"})
I would like to know if there is a better or efficient way to do so(maybe still use replace method)
Thanks!