I have values in a data frame with certain cells starting '< 101' and certain cells with '< 2' and some with '< 1'. I am trying to write regex using a Pandas Dataframe to find those cells and replace them entirely with the value '0.0'.
Here is what I have:
df_new2=df_new.replace('(?=<)','0', regex=True)
The above code simply adds a '0' in front of '< 101' with this output '0< 101'.
What I am looking for is an output that finds the '< 101' and replaces it with '0'. Is there a way to do this?
df_new2 = df_new.replace('^.*<.*$', '0', regex=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With