Skip to content

ENH: Make Series.explode work for sets #35614

Closed
@dsaxton

Description

@dsaxton

Currently Series.explode does nothing for sets but I think this would be just as useful as lists or tuples. It also allows for a way to easily enforce uniqueness at the row level before exploding.

I don't think this would be breaking, unless something is specifically relying on the operation not working.

import pandas as pd                                                                                                                                                                                  

ser = pd.Series([{1, 2}, {1, 2, 3}]) 
ser
# 0       {1, 2}
# 1    {1, 2, 3}
# dtype: object                                                                                                                                                               
ser.explode()                                                                                                                                                                                        
# 0       {1, 2}
# 1    {1, 2, 3}
# dtype: object

Desired output:

ser.explode()
# 0    1
# 0    2
# 1    1
# 1    2
# 1    3
# dtype: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions