I have data frame with a object column lets say col1, which has values likes: 1.00, 1, 0.50, 1.54
I want to have the output like the below: 1, 1, 0.5, 1.54 basically
How about the str.rstrip method. Like so (assuming your strings are in a list):
str.rstrip
a = ["1.00", "1" ,"0.50", "1.50"] b = [e.rstrip('.0') for e in a] >>> ['1', '1', '0.5', '1.5']