How to update column IsLCap column in dataframe based on Lvalue column whether it is capitilized or not.
df.loc[df.Lvalue.istitle(), 'IsLCap'] = 1 # need to be corrected
getting an error -AttributeError: 'Series' object has no attribute 'istitle'
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It only takes a minute to sign up.Sign up to join this community
You access string functions with
.str. This should work:
df.loc[df.Lvalue.str.istitle(), 'IsLCap'] = 1
To check the length of the strings in the column you can use the string method
df.loc[df.Lvalue.str.len() < 3, 'less_than_three'] = 1