Search code examples
pythonpandaslistpandas-loc

Select row using the length of list in pandas cell


I have a table df

    a   b    c
1   x   y   [x]

2   x   z   [c,d]

3   x   t   [e,f,g]

Just wondering how to select the row using the length of c column

such as

df.loc[len(df.c) >1]

I know this is not right.... what should be the right one?


Solution

  • You can using

    df.loc[np.array(list(map(len,df.c.values)))>1]