Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas turn column of list into binary

print(
    df.explode("categories")
    .pivot_table(
        index="item", columns="categories", aggfunc="size", fill_value=0
    )
    .reset_index()
)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #turn #column #list #binary
ADD COMMENT
Topic
Name
1+2 =