make length string in pandas
df['name_length'] = df.Name.str.len()
// or
df['name_length'] = df.Name.apply(len)
make length string in pandas
df['name_length'] = df.Name.str.len()
// or
df['name_length'] = df.Name.apply(len)
pandas apply check for string length in column
#The *mask* variable is a dataframe of booleans, giving you True or False for the selected condition
mask = df[['A','B']].applymap(lambda x: len(str(x)) == 10)
#Here you can just use the mask to filter your rows, using the method *.all()* to filter only rows that are all True, but you could also use the *.any()* method for other needs
df = df[mask.all(axis=1)]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us