I cant seem to find a way to split all of the array values from the column of a dataframe.
I have managed to get all the array values using this code:
I want to use value.counts() on the dataframe and I get this
I want the array values that are clubbed together to be split so that I can get the accurate count of every value.
Thanks in advance!
CodePudding user response:
You could try .explode(), which would create a new row for every value in each list.
df_mentioned_id_exploded = pd.DataFrame(df_mentioned_id.explode('entities.user_mentions'))
With the above code you would create a new dataframe df_mentioned_id_exploded
with a single column entities.user_mentions
, which you could then use .value_counts()
on.