I have a table in this format, which I would like to transform with the "opposite" of melting. There is another question that addresses this but it doesn't work with so many other columns that I'd like to keep.
The original:
COUNTRY STATE CATEGORY RESTAURANT STARS REVIEWS
US Texas NaN Texas Chicken 4.1 1,157
US Texas Spicy Texas Chicken 4.1 1,157
US Ohio NaN Mamas Shop 3.6 700
US Ohio NaN Pizza Hut 4.5 855
US Ohio Pizza Pizza Hut 4.5 855
The desired output:
COUNTRY STATE RESTAURANT STARS REVIEWS SPICY PIZZA
US Texas Texas Chicken 4.1 1,157 1 0
US Ohio Mamas Shop 3.6 700 0 0
US Ohio Pizza Hut 4.5 855 0 1
Essentially I would like to "group by" many columns, while creating extra columns based on the categories in the Category column. Restaurants that do not have any particular category would have the value 0 for all these additional columns. I also do not want any extra layers of columns as I am intending to write all of it to JSON.
Would appreciate any help on this and thank you in advance!