Skip to main content
`Ctrl`+`K`

# pandas.Timestamp

class pandas.Timestamp(ts_input=<object object>, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None, tzinfo=None, *, nanosecond=None, tz=<object object>, unit=None, fold=None)

  Pandas replacement for python datetime.datetime object.

  Timestamp is the pandas equivalent of python’s Datetime and is interchangeable with it in most cases. It’s the type used for the entries that make up a DatetimeIndex, and other timeseries oriented data structures in pandas.

  Parameters:
    ts_input datetime-like, str, int, float

      Value to be converted to Timestamp.

    year int

      Value of year.

    month int

      Value of month.

    day int

      Value of day.

    hour int, optional, default 0

      Value of hour.

    minute int, optional, default 0

      Value of minute.

    second int, optional, default 0

      Value of second.

    microsecond int, optional, default 0

      Value of microsecond.

    tzinfo datetime.tzinfo, optional, default None

      Timezone info.

    nanosecond int, optional, default 0

      Value of nanosecond.

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

      Time zone for time which Timestamp will have.

    unit str

      Unit used for conversion if ts_input is of type int or float. The valid values are ‘W’, ‘D’, ‘h’, ‘m’, ‘s’, ‘ms’, ‘us’, and ‘ns’. For example, ‘s’ means seconds and ‘ms’ means milliseconds.

      For float inputs, the result will be stored in nanoseconds, and the unit attribute will be set as `'ns'`.

    fold{0, 1}, default None, keyword-only

      Due to daylight saving time, one wall clock time can occur twice when shifting from summer to winter time; fold describes whether the datetime-like corresponds to the first (0) or the second time (1) the wall clock hits the ambiguous time.

  See also

  `Timedelta`

    Represents a duration, the difference between two dates or times.

  `datetime.datetime`

    Python datetime.datetime object.

  Notes

  There are essentially three calling conventions for the constructor. The primary form accepts four parameters. They can be passed by position or keyword.

  The other two forms mimic the parameters from `datetime.datetime`. They can be passed by either position or keyword, but not both mixed together.

  Examples

  Using the primary calling convention:

  This converts a datetime-like string

      >>> pd.Timestamp('2017-01-01T12')
      Timestamp('2017-01-01 12:00:00')

  This converts a float representing a Unix epoch in units of seconds

      >>> pd.Timestamp(1513393355.5, unit='s')
      Timestamp('2017-12-16 03:02:35.500000')

  This converts an int representing a Unix-epoch in units of weeks

      >>> pd.Timestamp(1535, unit='W')
      Timestamp('1999-06-03 00:00:00')

  This converts an int representing a Unix-epoch in units of seconds and for a particular timezone

      >>> pd.Timestamp(1513393355, unit='s', tz='US/Pacific')
      Timestamp('2017-12-15 19:02:35-0800', tz='US/Pacific')

  Using the other two forms that mimic the API for `datetime.datetime`:

      >>> pd.Timestamp(2017, 1, 1, 12)
      Timestamp('2017-01-01 12:00:00')

      >>> pd.Timestamp(year=2017, month=1, day=1, hour=12)
      Timestamp('2017-01-01 12:00:00')

  Attributes

  `asm8` | Return numpy datetime64 format with same precision.
  `day` | Return the day of the Timestamp.
  `day_of_week` | Return day of the week.
  `day_of_year` | Return the day of the year.
  `dayofweek` | Return day of the week.
  `dayofyear` | Return the day of the year.
  `days_in_month` | Return the number of days in the month.
  `daysinmonth` | Return the number of days in the month.
  `fold` | Return the fold value of the Timestamp.
  `hour` | Return the hour of the Timestamp.
  `is_leap_year` | Return True if year is a leap year.
  `is_month_end` | Check if the date is the last day of the month.
  `is_month_start` | Check if the date is the first day of the month.
  `is_quarter_end` | Check if date is last day of the quarter.
  `is_quarter_start` | Check if the date is the first day of the quarter.
  `is_year_end` | Return True if date is last day of the year.
  `is_year_start` | Return True if date is first day of the year.
  `max` |
  `microsecond` | Return the microsecond of the Timestamp.
  `min` |
  `minute` | Return the minute of the Timestamp.
  `month` | Return the month of the Timestamp.
  `nanosecond` | Return the nanosecond of the Timestamp.
  `quarter` | Return the quarter of the year for the Timestamp.
  `resolution` |
  `second` | Return the second of the Timestamp.
  `tz` | Alias for tzinfo.
  `tzinfo` | Returns the timezone info of the Timestamp.
  `unit` | The abbreviation associated with self._creso.
  `value` | Return the value of the Timestamp.
  `week` | Return the week number of the year.
  `weekofyear` | Return the week number of the year.
  `year` | Return the year of the Timestamp.

  Methods

  `as_unit`(unit[, round_ok]) | Convert the underlying int64 representation to the given unit.
  `astimezone`(tz) | Convert timezone-aware Timestamp to another time zone.
  `ceil`(freq[, ambiguous, nonexistent]) | Return a new Timestamp ceiled to this resolution.
  `combine`(date, time) | Combine a date and time into a single Timestamp object.
  `ctime`() | Return a ctime() style string representing the Timestamp.
  `date`() | Returns datetime.date with the same year, month, and day.
  `day_name`([locale]) | Return the day name of the Timestamp with specified locale.
  `dst`() | Return the daylight saving time (DST) adjustment.
  `floor`(freq[, ambiguous, nonexistent]) | Return a new Timestamp floored to this resolution.
  `fromisocalendar` | int, int, int -> Construct a date from the ISO year, week number and weekday.
  `fromisoformat` | string -> datetime from a string in most ISO 8601 formats
  `fromordinal`(ordinal[, tz]) | Construct a timestamp from a proleptic Gregorian ordinal.
  `fromtimestamp`(ts[, tz]) | Create a Timestamp object from a POSIX timestamp.
  `isocalendar`() | Return a named tuple containing ISO year, week number, and weekday.
  `isoformat`([sep, timespec]) | Return the time formatted according to ISO 8601.
  `isoweekday`() | Return the day of the week represented by the date.
  `month_name`([locale]) | Return the month name of the Timestamp with specified locale.
  `normalize`() | Normalize Timestamp to midnight, preserving tz information.
  `now`([tz]) | Return new Timestamp object representing current time local to tz.
  `replace`([year, month, day, hour, minute, ...]) | Implements datetime.replace, handles nanoseconds.
  `round`(freq[, ambiguous, nonexistent]) | Round the Timestamp to the specified resolution.
  `strftime`(format) | Return a formatted string of the Timestamp.
  `strptime`(date_string, format) | Convert string argument to datetime.
  `time`() | Return time object with same time but with tzinfo=None.
  `timestamp`() | Return POSIX timestamp as float.
  `timetuple`() | Return time tuple, compatible with time.localtime().
  `timetz`() | Return time object with same time and tzinfo.
  `to_datetime64`() | Return a NumPy datetime64 object with same precision.
  `to_julian_date`() | Convert TimeStamp to a Julian Date.
  `to_numpy`([dtype, copy]) | Convert the Timestamp to a NumPy datetime64.
  `to_period`([freq]) | Return a period of which this timestamp is an observation.
  `to_pydatetime`([warn]) | Convert a Timestamp object to a native Python datetime object.
  `today`([tz]) | Return the current time in the local timezone.
  `toordinal`() | Return proleptic Gregorian ordinal.
  `tz_convert`(tz) | Convert timezone-aware Timestamp to another time zone.
  `tz_localize`(tz[, ambiguous, nonexistent]) | Localize the Timestamp to a timezone.
  `tzname`() | Return time zone name.
  `utcfromtimestamp`(ts) | Construct a timezone-aware UTC datetime from a POSIX timestamp.
  `utcnow`() | Return a new Timestamp representing UTC day and time.
  `utcoffset`() | Return utc offset.
  `utctimetuple`() | Return UTC time tuple, compatible with time.localtime().
  `weekday`() | Return the day of the week represented by the date.