I have column like below:
col1
Q123
Q456
abc
scg
I want to keep only values starting with Q i.e, Q123,Q456 treat other than those values as none.
I tried like below:
data.col1 = data.col1.apply(lambda value: 'none' if not startswith("Q") in str(value) else value)
I am getting NameError: name 'startswith' is not defined
Please,help me where am gone wrong?
Aucun commentaire:
Enregistrer un commentaire