pandas.Timestamp.fromordinal#

classmethod Timestamp.fromordinal(ordinal, tz=None)#

Construct a timestamp from a a proleptic Gregorian ordinal.

This method creates a Timestamp object corresponding to the given proleptic Gregorian ordinal, which is a count of days from January 1, 0001 (using the proleptic Gregorian calendar). The time part of the Timestamp is set to midnight (00:00:00) by default.

Parameters:
ordinalint

Date corresponding to a proleptic Gregorian ordinal.

tzstr, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None

Time zone for the Timestamp.

Returns:
Timestamp

A Timestamp object representing the specified ordinal date.

See also

Timestamp

Represents a single timestamp, similar to datetime.

to_datetime

Converts various types of data to datetime.

Notes

By definition there cannot be any tz info on the ordinal itself.

Examples

Convert an ordinal to a Timestamp:

>>> pd.Timestamp.fromordinal(737425)
Timestamp('2020-01-01 00:00:00')

Create a Timestamp from an ordinal with timezone information:

>>> pd.Timestamp.fromordinal(737425, tz='UTC')
Timestamp('2020-01-01 00:00:00+0000', tz='UTC')