I have a Pandas Dataframe: I wanted to calculate the length of each cell in row index=4. I executed 2 commands and both give different answers. Can somebody explain what is happening here
a b c d e f g
0 1 2 3 4 5 6 first
1 3 4 5 6 7 8 second
2 6 7 8 9 10 11 third
3 first second third fourth fifth sixth fourth
4 column column column column column column fifth
First Command:
**df2.loc[4].apply(lambda x: len(x))**
Output:
a 6
b 6
c 6
d 6
e 6
f 6
g 5
Name: 4, dtype: int64
Second Command:
**df2.loc[4:].apply(lambda x: len(x))**
Output:
a 1
b 1
c 1
d 1
e 1
f 1
g 1
dtype: int64
- New to Python