Question:
I have a dataframe with two columns for two kinds of rates. But the data inconsistency there has made it difficult to differentiate thousand rates from the normal rates. So, I need to find a pattern of {dot}{3digits} and replace the first dot with blank. So I have created a function to take care of that. But the function is not working as expected and I’m getting an error/warning as below. What could be the issue here?
Answer:
Although yourif
statement did found patterns of '\\.\\d{3}'
, the subsequent sub
operation did not take consideration of that. It will just remove the first dot.You could use a regex to find out pattern of
'\\.\\d{3}'
, then capture the digits, and replace the whole thing with the capture group (i.e. the digits).If you have better answer, please add a comment about this, thank you!