Home > Blockchain >  I have a dataframe containing arrays, is there a way collect all of the elements and store it in a s
I have a dataframe containing arrays, is there a way collect all of the elements and store it in a s

Time:11-04

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: enter image description here

The dataframe is as follows: enter image description here

I want to use value.counts() on the dataframe and I get thisenter image description here

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.

  • Related