Skip to content
Advertisement

How to get the average of average of a column of list of lists as string data type?

I have a dataframe with a column like this:

JavaScript

It shows the probability of one word in one sentence in one paragraph, the number of words and sentences is random. I would like to get another column average_prob that is the average of the average of each row. so basically 0.225 and 0.25 here.

The data type of column word_probs is string.

How can I achieve this? Thanks a lot in advance!

Advertisement

Answer

We need first convert the string to list with ast , then we do explode

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement