Custom Lambda DataFrame
import pandas as pddata = ['Vachitaya aapuuuuuuuuu','Sing in the rain' ,'Great power comes wih great responsibility']
df = pd.DataFrame(data, columns = ['Sent'])
df| Sent | |
|---|---|
| 0 | Vachitaya aapuuuuuuuuu |
| 1 | Sing in the rain |
| 2 | Great power comes wih great responsibility |
def sent_length(message):
return (len(message))df['len'] = df['Sent'].apply(sent_length)df| Sent | len | |
|---|---|---|
| 0 | Vachitaya aapuuuuuuuuu | 22 |
| 1 | Sing in the rain | 16 |
| 2 | Great power comes wih great responsibility | 42 |