Pandas Timestamp function combine() in Python
The Pandas Timestamp function combine() used to combine the date and time into datetime with same date and time filed. It returns Timestamp object that includes specified date and time values.
Syntax
 1 classmethod Timestamp.combine(date, time)
date : It is date value to set the date in the Timestamp object.
time : It is time value to set the time in the Timestamp object.
combine() function
 1 import pandas as pd
 2 from datetime import date, time
 3 
 4 dt = date(2022, 5, 25)
 5 tm = time(15, 45, 57, 123)
 6 
 7 print('The original date object :')
 8 print(dt)
 9 
 10 print('The original time object :')
 11 print(tm)
 12 
 13 res = pd.Timestamp.combine(dt, tm)
 14 print('The combined Timestamp object :')
 15 print(res)
In the above example, a time and date object is created by passing an date and time value. A Timestamp function combine() called by passing a date time value. It combine the date and time value into Timestamp object and assign result to the variable that will be printed on console.
Output
 1 The original date object :
 2 2022-05-25
 3 
 4 The original time object :
 5 15:45:57.000123
 6 
 7 The combined Timestamp object :
 8 2022-05-25 15:45:57.000123

Example 2

Example 2
 1 import pandas as pd
 2 from datetime import date, time
 3 
 4 dt = date(2023, 11, 23)
 5 tm = time(22, 55, 14, 110001)
 6 
 7 print('The original date object :')
 8 print(dt)
 9 
 10 print('The original time object :')
 11 print(tm)
 12 
 13 res = pd.Timestamp.combine(dt, tm)
 14 print('The combined Timestamp object :')
 15 print(res)
In the above example, a time and date object is created by passing an date and time value. A Timestamp function combine() called by passing a date time value. It combine the date and time value into Timestamp object and assign result to the variable that will be print.
Output
 1 The original date object :
 2 2023-11-23
 3 
 4 The original time object :
 5 22:55:14.110001
 6 
 7 The combined Timestamp object :
 8 2023-11-23 22:55:14.110001
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us