Convert Categorical data to Numerical data in for loop in python pandas


Talha Ramzan

I have a categorical data framework and I want to convert it into numerical data, I have more than 50 columns so I want to run .replace command in a loop.

replace_map = {'w': 4, '+': 5, '.': 6, 'g': 7}

and I have written code which iterates over columns

for column in df1_replace.columns[1:76]:
# Select column contents by column name using [] operator
columnSeriesObj = df1_replace[column]
print('Colunm Name : ', column)
print('Column Contents : ', columnSeriesObj.values)

Continue reading...