Python Forum
Conversion of Time Duration in seconds in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conversion of Time Duration in seconds in python
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Conversion of Oracle PL/SQL(packages, functions, procedures) to python modules. DivyaKumar 3 8,289 Oct-01-2024, 03:32 PM
Last Post: Alex_Kirpichny
  how to correctly set duration of video clips to merge? oxidian 1 837 Aug-03-2024, 05:35 PM
Last Post: oxidian
  Problem with module time and leap seconds Pedroski55 3 2,085 Oct-07-2022, 11:27 PM
Last Post: Pedroski55
  I need to add data types to cython conversion python to c Good_AI_User 1 1,759 Aug-19-2022, 07:52 AM
Last Post: Gribouillis
  How to change UTC time to local time in Python DataFrame? SamKnight 2 2,720 Jul-28-2022, 08:23 AM
Last Post: Pedroski55
  Store variable data and display sum after 60 seconds the_dude 11 5,579 Dec-16-2021, 07:07 PM
Last Post: deanhystad
  Time conversion error tester_V 1 2,593 Oct-28-2020, 10:48 PM
Last Post: tester_V
  How to calculate time difference between each row of dataframe in seconds Mekala 1 3,607 Jul-16-2020, 12:57 PM
Last Post: Larz60+
  Need to add hours min and seconds tester_V 5 4,281 Jun-02-2020, 05:29 PM
Last Post: tester_V
  C to Python code conversion print problem anakk1n 1 2,760 May-22-2020, 04:15 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020