You could use np.size:
In [301]: file = pd.Series([['junior','senior'], 'freshgrad'])
In [302]: file.apply(np.size)
Out[302]:
0 2
1 1
dtype: int64
In [327]: np.size(file[0])
Out[327]: 2
In [328]: np.size(file[1])
Out[328]: 1
But to some extent this might just be delaying your agony. When the objects in
a Series (or any kind sequence) have different types, the code tends require type-checking or try..excepts to handle the various types differently. (In fact, this is what np.size is doing. Under the hood np.size is using try..except to handle the exceptional case.)
Life is usually simpler (and therefore better) when all the objects in a sequence have the same type. So it is preferable to build a Series whose elements are all lists:
In [301]: file = pd.Series([['junior','senior'], ['freshgrad']])
1 ['freshgrad']you would getlen(file[1])=1freshgradis currently a string, and you want it to be an array.