Python | Pandas Timestamp.to_julian_date

Python Methods and Functions

The Pandas function Timestamp.to_julian_date() converts a given timestamp to a Julian date. Julian date value 0 — noon January 1, 4713 BC

Syntax: Timestamp.to_julian_date ()

Parameters: None

Return: julian date

Example # 1: Use the Timestamp.to_julian_date () function to convert the given timestamp to a Julian date.

# import pandas as pd

import pandas as pd

 
# Create Timestamp object

ts = pd.Timestamp (year = 2011 , month = 11 , d ay = 21

hour = 10 , second = 49 , tz = 'US / Central'

 
# Print Timestamp object

print (ts)

Output:

We will now use the Timestamp.to_julian_date () function to convert a given timestamp to a Julian date.

# convert to Julian date
ts.to_julian_date ()

Output:

As we see in the output, the Timestamp.to_julian_date () function converted the given timestamp to a Julian date.

Example # 2: Use the Timestamp.to_julian_date () function to convert the given timestamp to a Julian date.

# import pandas as pd

import pandas as pd

 
# Create Timestamp object

ts = pd.Timestamp (year = 2009 , month = 5 , day = 31

hour = 4 , second = 49 , tz = 'Europe / Berlin' )

 
# Print the Timestamp object

print (ts)

Output:

We will now use the Timestamp.to_julian_date () function to convert this timestamp to Julian date.

# convert to Julian date
ts.to_julian_date ()

Output:

As we can see in the output, the Timestamp.to_julian_date () function has transformed this timestamp in Julian date.





Get Solution for free from DataCamp guru