I have the following data structure.
basket_series = df_train["basket"].head(10)
type(basket_series)
Output: pandas.core.series.Series
0 [3]
1 [5, 3, 0, 3]
2 [3, 3, 1, 4]
3 [2]
4 [4, 4, 4, 4]
5 [4, 3, 4, 4]
6 [3, 4]
7 [4, 4, 1, 4, 4]
8 [1, 5, 2, 2]
9 [5, 5, 0]
I want to know how many numbers are per "list" -> but I think that "the list" is only interpreted as a string. My approaches were:
basket_series.size()
output: 10
for x in basket_series:
print(len(x))
output: 3 12 12 3 12 12 6 15 12 9
Which seems to be the same as
basket_series.str.len()
for x in basket_series:
print(len(list(x)))
So the problem is that it is seen as a string? Do you have any ideas?