Jun-05-2018, 05:12 PM
(This post was last modified: Jun-05-2018, 05:14 PM by jdevansh99.)
import re
match = re.match(r'PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?', 'PT7M37S')
(hours, minutes, seconds) = [ int(n or 0) for n in match.groups() ]
A=hours*60*60+ minutes*60+ seconds
This works for a single string.
But i have a dataset, with multiple columns, and i want to apply this operation to one of the columns in the dataset. Can anybody tell me how will that work?
match = re.match(r'PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?', 'PT7M37S')
(hours, minutes, seconds) = [ int(n or 0) for n in match.groups() ]
A=hours*60*60+ minutes*60+ seconds
This works for a single string.
But i have a dataset, with multiple columns, and i want to apply this operation to one of the columns in the dataset. Can anybody tell me how will that work?