#Add the new column which gives a unique number to each of these labels df['label_num'] = df['label'].map({ 'Household' : 0, 'Books': 1, 'Electronics': 2, 'Clothing & Accessories': 3 }) #checking the results df.head(5)
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