I have a dataframe that looks like this.
userID upvotes
abc1998 [abc1298]
abc1998 [abc0369,abc9999]
abc1998 []
abc1998 []
abc1998 []
abc1998 [abc1991, abc1235]
abc1998 [abc1992]
I want to add the length of the list of each column of the row 'upvotes' and store it in a variable ie, the output should be sum = 1+2+0+0+0+2+1 = 6
Any help on this please?
df.upvotes.str.len().sum()
This worked! Thanks @yatu
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.