#Label Encoding from sklearn.preprocessing import OneHotEncoder, LabelEncoder import pandas as pd data = { 'Color': ['Red', 'Green', 'Blue', 'Red', 'Blue', 'Green', 'Green'] } df = pd.DataFrame(data) label_encoder = LabelEncoder() data['Color-Label'] = label_encoder.fit_transform(data['Color']) df = pd.DataFrame(data) df
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter