I want to extract specific content from string. Consider the following dataframe:
data = {'time': [0, 1, 2, 3, 4], 'id': ["bike0", "bike10", "veh0", "veh10", "moto100"]}
df = pd.DataFrame(data)
I would like to extract with a regular expression the digit value in the string. The final result should be:
data = {'time': [0, 1, 2, 3, 4], 'id': [0, 10, 0, 10, 100]}
df = pd.DataFrame(data)
The difficulty here is that the length of the string and the number of digits to extract are variable.
Thanks for help.