pandas.Timestamp.fromtimestamp — pandas 3.0.0.dev0+2104.ge637b4290d documentation (original) (raw)
classmethod Timestamp.fromtimestamp(ts, tz=None)#
Create a Timestamp object from a POSIX timestamp.
This method converts a POSIX timestamp (the number of seconds since January 1, 1970, 00:00:00 UTC) into a Timestamp object. The resultingTimestamp can be localized to a specific time zone if provided.
Parameters:
tsfloat
The POSIX timestamp to convert, representing seconds since the epoch (1970-01-01 00:00:00 UTC).
tzstr, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile, optional
Time zone for the Timestamp. If not provided, the Timestamp will be timezone-naive (i.e., without time zone information).
Returns:
Timestamp
A Timestamp object representing the given POSIX timestamp.
Examples
Convert a POSIX timestamp to a Timestamp:
pd.Timestamp.fromtimestamp(1584199972)
Timestamp('2020-03-14 15:32:52')
Note that the output may change depending on your local time and time zone:
pd.Timestamp.fromtimestamp(1584199972, tz='UTC')
Timestamp('2020-03-14 15:32:52+0000', tz='UTC')