With split and join
','.join(input_str.split(',')[:-1])
Explanation
# Split string by the commas
>>> input_str.split(',')
['2548', '0.8987', '0.8987', '0.1548']
# Take all but last part
>>> input_str.split(',')[:-1]
['2548', '0.8987', '0.8987']
# Join the parts with commas
>>> ','.join(input_str.split(',')[:-1])
'2548,0.8987,0.8987'
With rsplit
input_str.rsplit(',', maxsplit=1)[0]
With re
re.sub(r',[^,]*$', '', input_str)
If you are gonna to use it multiple times make sure to compile the regex:
LAST_ELEMENT_REGEX = re.compile(r',[^,]*$')
LAST_ELEMENT_REGEX.sub('', input_str)