'Remove leading zeros only in case of integers datatype

I want to remove leading zeros only in case of integer values. I have tried the following:

df['col'].str.replace(r'^0+(?=[[0-9]])', '', regex=True)

However this does not work. Does anybody know how to achieve this?



Solution 1:[1]

This probably works:

df['CRITERIA_VALUE'] = df['CRITERIA_VALUE'].str.apply(lambda x: int(x))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sadra