Skip to content
Advertisement

extract new columns and fill values based on categorical values data frame in python

I have a data frame where one column is categorical strings and the next one is the values corresponding to it:

JavaScript

initial df with too many rows that are duplicated

I want to create new columns based on df.status column, and fill empty ones with np.nan, requires pivot on multiple columns:

result df after pivot on multiple indexes

I am looking for an efficient solution that works for large data frames.

Advertisement

Answer

You want:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement