I'm trying to count the number of unique values in a dataframe column using pandas.Series.explode as I'm not interested in exploding the entire dataframe. The dataframe column I'm trying to explode looks like
df["lists"].head()
0 [cl5, bn6, sp1]
1 [cl5, bn6, sp1]
2 [cl5, bn6, sp1]
3 [bn6, sp1]
4 [bn6, sp1]
Name: lists, dtype: object
I tried df.lists.explode().value_counts()
which throws an AttributeError: 'Series' object has no attribute 'explode'.
The same error is observed while exploding the entire dataframe with df.explode('lists')
. I cannot see if it been deprecated so I'm not sure what's wrong when the source examples don't work either.