I have the following data structure. In which the category names are mixed with the product names
df = pd.DataFrame(data={'name':['Category A', 'Subcategory A.A', 'Product A', 'Product B', 'Category B', 'Product C'],'values':["", "", 1,2,"", 3]})
name values
Category A
Subcategory A.A
Product A 1
Product B 2
Category B
Product C 3
Every entry in the name
column which does not have a value is a category name.
Is there any way to convert the pandas DataFrame into the following structure?
name values category
Product A 1 Category A, Subcategory A.A
Product B 2 Category A, Subcategory A.A
Product C 3 Category B
Any help is appreciated.