ENH: Make Series.explode work for sets (original) (raw)

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