Hi,
Thanks for registering with ProjectPro Recipes - get just-in-time learning and release your projects faster with "ready-to-use" Data-Science code snippets.Â
Find below a recipe we launched recently -Â
How to convert string categorical variables into numerical variables using Label Encoder?
Download the code for this recipe and access 1000+ recipes
## How to convert string categorical variables into numerical variables using Label Encoder
def Kickstarter_Example_78():
print()
print(format('How to convert strings into numerical variables using Label Encoder','*^82'))
import warnings
warnings.filterwarnings("ignore")
# load libraries
import pandas as pd
from sklearn.preprocessing import LabelEncoder
# Create dataframe
raw_data = {'patient': [1, 1, 1, 2, 2],
'obs': [1, 2, 3, 1, 2],
'treatment': [0, 1, 0, 1, 0],
'score': ['strong', 'weak', 'normal', 'weak', 'strong']}........
.
.
.
View the complete recipe
Get access to solved, end-to-end projects using such recipes - price increases on March 26
|