Conversion of Time Duration in seconds in python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Conversion of Time Duration in seconds in python (/thread-10768.html) |
Conversion of Time Duration in seconds in python - jdevansh99 - Jun-05-2018 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? |