I have a column where values are lists of strings, i.e.
Input:
df = pd.DataFrame({'Food': [[''], ['potato', 'carrot'], ['potato', '']]})
that looks like:
Food
['']
['potato', 'carrot']
['potato', '']
When I perform df['Count'] = df['Food'].str.len(), I get:
Food Count
[''] 1
['potato', 'carrot'] 2
['potato', ''] 2
However, I want to get:
Food Count
[''] 0
['potato', 'carrot'] 2
['potato', ''] 1