Lambda Function
import pandas as pd
content = ['hi','hello','how are you']
df=pd.DataFrame(content,columns={'Sms content'})
df
Sms content | |
---|---|
0 | hi |
1 | hello |
2 | how are you |
df['msg_length'] = df['Sms content'].apply(lambda x:len(x))
df.head()
Sms content | msg_length | |
---|---|---|
0 | hi | 2 |
1 | hello | 5 |
2 | how are you | 11 |