EN VI

Replacing < containing values in Python dataframe?

2024-03-12 16:00:06
How to 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().

Solution:

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

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login