Pegasus101
IS-IT--Management
Thank you in advance for your help.
There is a products table in a csv that has multiple products. I need to create an ordinal list of the ranking of the products in descending order, so that a list is created with the ranking of the products most sold.
I thought that using the dictionary comprehensions are te way to go, but couldn't get further than the code below, which creates a list of the products alphabetically but doesnt list rank them as the products most sold.
Many thanks and let me know if you need more information.
There is a products table in a csv that has multiple products. I need to create an ordinal list of the ranking of the products in descending order, so that a list is created with the ranking of the products most sold.
I thought that using the dictionary comprehensions are te way to go, but couldn't get further than the code below, which creates a list of the products alphabetically but doesnt list rank them as the products most sold.
Code:
labels = df['PRODUCT_NAME'].astype('category').cat.categories.tolist()
replace_map_comp = {'PRODUCT_NAME' : {k: v for k,v in zip(labels,list(range(1,len(labels)+1)))}}
print(replace_map_comp)
Many thanks and let me know if you need more information.