I have a dataframe users which consists of three columns id, username and password.
I am trying to get a count of the rows which have less than 8 numbers of characters in password.
My code:
# Calculating the length of user's passwords
users['length'] = users.password.str.len()
# Flagging the users with too short passwords`
users['too_short'] = pd.cut(users['length'], bins=[0,7,300], labels=[True,False])
print (users[users['too_short'].any(1)])
# Counting and printing the number of users with too short passwords
print(users['too_short'].count())
# Taking a look at the 12 first rows
users.head(12)
It gives the following error:
TypeError: Categorical cannot perform the operation any
Column too_short has a value either True or False. I am trying to find a way to count the number of rows in this column based on the boolean values, but with no luck.