Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Replacing < containing values in Python dataframe

I have a dataframe, and in some columns there are values such as "<0.5, <10, <100" etc. I want to replace all those values with 0 if the value just contains "<". How can I do it? I’m relatively new with Python.

Tried to use pd.DataFrame.replace().

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

df[df["Column"].str.contains("<",na=False)]=0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading