I just want to add a if condition before a regex matching: first I define the regex and store the values in Name, then I print the Name value. The result is True and False(Boolean).
Name = df['Name'].str.match('^(\w+\s*)$')
#If the result matches True value passed and else the value will be False
print(Name)
Result
:
True
False
True
The below code is about the if condition I have. I don't know how to match if condition with a regex. It seems the value of Name which is True/ False hasn't been checked in the if condition.
if Name is True:
print(Name)
else:
print('bye')
Code Result:
bye
Expected Result:
John
Saher
Thanks
df.loc[Name,'Name'].