Python Pandas: How do I get the length of arrays that are values of a column?

Python Pandas: How do I get the length of arrays that are values of a column?
0

#1

Hi all,

I found a problem where the values of a column are arrays of different length. What is the best, efficient way to get the values of the length of each array in that column?

EDIT (following PortableStick advice):

Cannot reproduce the code, but the structure of the pandas data frame seems to be:

arr_of_arrs = [ [ 1,2,3 ] , [ 1,2,3,4 ] , [ 1,2,3,4,5 ] ]
pf = pd.DataFrame(arr_of_arrs, columns=[ 'arrofarrs' ])

Thanks in advance


#2

Can you post the code you’re working on so we have some context?


#4

df["desired column"].apply(lambda x: len(x))