Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
Increment initial time value in floating seconds?

I have an initial time value like 15:59:26.186000 (format %H:%M:%S.%f).

And a pandas DataFrame with a seconds as floats

SECONDS
0.44121
0.92844 
1.60995 
2.16770  
2.87059 

Is there any way to add those seconds to the initial value? So first row would be 15:29:26.627, etc.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use pd.to_timedelta to convert the Series to a delta, and add it to a datetime version of the initial value:

s = pd.Series([0.44121, 0.92844, 1.60995, 2.16770, 2.87059])
t = '15:59:26.186000'
pd.to_timedelta(s, unit='s') + pd.to_datetime(t, format='%H:%M:%S.%f')
over 4 years ago · Santiago Trujillo Report

0

You can use pd.to_timedelta with unit to convert SECONDS to time and add:

df['SECONDS'] = pd.Timedelta('15:59:26.186000') + pd.to_timedelta(df['SECONDS'], unit='s')

You can also multiply:

df['SECONDS'] = pd.Timedelta('15:59:26.186000') + df['SECONDS'] * pd.Timedelta('1s')

Output:

                 SECONDS
0 0 days 15:59:26.627210
1 0 days 15:59:27.114440
2 0 days 15:59:27.795950
3 0 days 15:59:28.353700
4 0 days 15:59:29.056590
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!