doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
pandas.Timedelta.resolution Timedelta.resolution=Timedelta('0 days 00:00:00.000000001')
pandas.reference.api.pandas.timedelta.resolution
pandas.Timedelta.resolution_string Timedelta.resolution_string Return a string representing the lowest timedelta resolution. Each timedelta has a defined resolution that represents the lowest OR most granular level of precision. Each level of resolution is represented by a short string as defined below: Resolution: Return value Days: ‘D’ Hours: ‘H’ Minutes: ‘T’ Seconds: ‘S’ Milliseconds: ‘L’ Microseconds: ‘U’ Nanoseconds: ‘N’ Returns str Timedelta resolution. Examples >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') >>> td.resolution_string 'N' >>> td = pd.Timedelta('1 days 2 min 3 us') >>> td.resolution_string 'U' >>> td = pd.Timedelta('2 min 3 s') >>> td.resolution_string 'S' >>> td = pd.Timedelta(36, unit='us') >>> td.resolution_string 'U'
pandas.reference.api.pandas.timedelta.resolution_string
pandas.Timedelta.round Timedelta.round(freq) Round the Timedelta to the specified resolution. Parameters freq:str Frequency string indicating the rounding resolution. Returns a new Timedelta rounded to the given resolution of freq Raises ValueError if the freq cannot be converted
pandas.reference.api.pandas.timedelta.round
pandas.Timedelta.seconds Timedelta.seconds Number of seconds (>= 0 and less than 1 day).
pandas.reference.api.pandas.timedelta.seconds
pandas.Timedelta.to_numpy Timedelta.to_numpy() Convert the Timedelta to a NumPy timedelta64. New in version 0.25.0. This is an alias method for Timedelta.to_timedelta64(). The dtype and copy parameters are available here only for compatibility. Their values will not affect the return value. Returns numpy.timedelta64 See also Series.to_numpy Similar method for Series.
pandas.reference.api.pandas.timedelta.to_numpy
pandas.Timedelta.to_pytimedelta Timedelta.to_pytimedelta() Convert a pandas Timedelta object into a python datetime.timedelta object. Timedelta objects are internally saved as numpy datetime64[ns] dtype. Use to_pytimedelta() to convert to object dtype. Returns datetime.timedelta or numpy.array of datetime.timedelta See also to_timedelta Convert argument to Timedelta type. Notes Any nanosecond resolution will be lost.
pandas.reference.api.pandas.timedelta.to_pytimedelta
pandas.Timedelta.to_timedelta64 Timedelta.to_timedelta64() Return a numpy.timedelta64 object with ‘ns’ precision.
pandas.reference.api.pandas.timedelta.to_timedelta64
pandas.Timedelta.total_seconds Timedelta.total_seconds() Total seconds in the duration.
pandas.reference.api.pandas.timedelta.total_seconds
pandas.Timedelta.value Timedelta.value
pandas.reference.api.pandas.timedelta.value
pandas.Timedelta.view Timedelta.view() Array view compatibility.
pandas.reference.api.pandas.timedelta.view
pandas.timedelta_range pandas.timedelta_range(start=None, end=None, periods=None, freq=None, name=None, closed=None)[source] Return a fixed frequency TimedeltaIndex, with day as the default frequency. Parameters start:str or timedelta-like, default None Left bound for generating timedeltas. end:str or timedelta-like, default None Right bound for generating timedeltas. periods:int, default None Number of periods to generate. freq:str or DateOffset, default ‘D’ Frequency strings can have multiples, e.g. ‘5H’. name:str, default None Name of the resulting TimedeltaIndex. closed:str, default None Make the interval closed with respect to the given frequency to the ‘left’, ‘right’, or both sides (None). Returns TimedeltaIndex Notes Of the four parameters start, end, periods, and freq, exactly three must be specified. If freq is omitted, the resulting TimedeltaIndex will have periods linearly spaced elements between start and end (closed on both sides). To learn more about the frequency strings, please see this link. Examples >>> pd.timedelta_range(start='1 day', periods=4) TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', freq='D') The closed parameter specifies which endpoint is included. The default behavior is to include both endpoints. >>> pd.timedelta_range(start='1 day', periods=4, closed='right') TimedeltaIndex(['2 days', '3 days', '4 days'], dtype='timedelta64[ns]', freq='D') The freq parameter specifies the frequency of the TimedeltaIndex. Only fixed frequencies can be passed, non-fixed frequencies such as ‘M’ (month end) will raise. >>> pd.timedelta_range(start='1 day', end='2 days', freq='6H') TimedeltaIndex(['1 days 00:00:00', '1 days 06:00:00', '1 days 12:00:00', '1 days 18:00:00', '2 days 00:00:00'], dtype='timedelta64[ns]', freq='6H') Specify start, end, and periods; the frequency is generated automatically (linearly spaced). >>> pd.timedelta_range(start='1 day', end='5 days', periods=4) TimedeltaIndex(['1 days 00:00:00', '2 days 08:00:00', '3 days 16:00:00', '5 days 00:00:00'], dtype='timedelta64[ns]', freq=None)
pandas.reference.api.pandas.timedelta_range
pandas.TimedeltaIndex classpandas.TimedeltaIndex(data=None, unit=None, freq=NoDefault.no_default, closed=None, dtype=dtype('<m8[ns]'), copy=False, name=None)[source] Immutable ndarray of timedelta64 data, represented internally as int64, and which can be boxed to timedelta objects. Parameters data:array-like (1-dimensional), optional Optional timedelta-like data to construct index with. unit:unit of the arg (D,h,m,s,ms,us,ns) denote the unit, optional Which is an integer/float number. freq:str or pandas offset object, optional One of pandas date offset strings or corresponding objects. The string ‘infer’ can be passed in order to set the frequency of the index as the inferred frequency upon creation. copy:bool Make a copy of input ndarray. name:object Name to be stored in the index. See also Index The base pandas Index type. Timedelta Represents a duration between two dates or times. DatetimeIndex Index of datetime64 data. PeriodIndex Index of Period data. timedelta_range Create a fixed-frequency TimedeltaIndex. Notes To learn more about the frequency strings, please see this link. Attributes days Number of days for each element. seconds Number of seconds (>= 0 and less than 1 day) for each element. microseconds Number of microseconds (>= 0 and less than 1 second) for each element. nanoseconds Number of nanoseconds (>= 0 and less than 1 microsecond) for each element. components Return a dataframe of the components (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) of the Timedeltas. inferred_freq Tries to return a string representing a frequency guess, generated by infer_freq. Methods to_pytimedelta(*args, **kwargs) Return Timedelta Array/Index as object ndarray of datetime.timedelta objects. to_series([index, name]) Create a Series with both index and values equal to the index keys. round(*args, **kwargs) Perform round operation on the data to the specified freq. floor(*args, **kwargs) Perform floor operation on the data to the specified freq. ceil(*args, **kwargs) Perform ceil operation on the data to the specified freq. to_frame([index, name]) Create a DataFrame with a column containing the Index. mean(*args, **kwargs) Return the mean value of the Array.
pandas.reference.api.pandas.timedeltaindex
pandas.TimedeltaIndex.ceil TimedeltaIndex.ceil(*args, **kwargs)[source] Perform ceil operation on the data to the specified freq. Parameters freq:str or Offset The frequency level to ceil the index to. Must be a fixed frequency like ‘S’ (second) not ‘ME’ (month end). See frequency aliases for a list of possible freq values. ambiguous:‘infer’, bool-ndarray, ‘NaT’, default ‘raise’ Only relevant for DatetimeIndex: ‘infer’ will attempt to infer fall dst-transition hours based on order bool-ndarray where True signifies a DST time, False designates a non-DST time (note that this flag is only applicable for ambiguous times) ‘NaT’ will return NaT where there are ambiguous times ‘raise’ will raise an AmbiguousTimeError if there are ambiguous times. nonexistent:‘shift_forward’, ‘shift_backward’, ‘NaT’, timedelta, default ‘raise’ A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. ‘shift_forward’ will shift the nonexistent time forward to the closest existing time ‘shift_backward’ will shift the nonexistent time backward to the closest existing time ‘NaT’ will return NaT where there are nonexistent times timedelta objects will shift nonexistent times by the timedelta ‘raise’ will raise an NonExistentTimeError if there are nonexistent times. Returns DatetimeIndex, TimedeltaIndex, or Series Index of the same type for a DatetimeIndex or TimedeltaIndex, or a Series with the same index for a Series. Raises ValueError if the freq cannot be converted. Notes If the timestamps have a timezone, ceiling will take place relative to the local (“wall”) time and re-localized to the same timezone. When ceiling near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples DatetimeIndex >>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min') >>> rng DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00', '2018-01-01 12:01:00'], dtype='datetime64[ns]', freq='T') >>> rng.ceil('H') DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00', '2018-01-01 13:00:00'], dtype='datetime64[ns]', freq=None) Series >>> pd.Series(rng).dt.ceil("H") 0 2018-01-01 12:00:00 1 2018-01-01 12:00:00 2 2018-01-01 13:00:00 dtype: datetime64[ns] When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized. >>> rng_tz = pd.DatetimeIndex(["2021-10-31 01:30:00"], tz="Europe/Amsterdam") >>> rng_tz.ceil("H", ambiguous=False) DatetimeIndex(['2021-10-31 02:00:00+01:00'], dtype='datetime64[ns, Europe/Amsterdam]', freq=None) >>> rng_tz.ceil("H", ambiguous=True) DatetimeIndex(['2021-10-31 02:00:00+02:00'], dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
pandas.reference.api.pandas.timedeltaindex.ceil
pandas.TimedeltaIndex.components propertyTimedeltaIndex.components Return a dataframe of the components (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) of the Timedeltas. Returns DataFrame
pandas.reference.api.pandas.timedeltaindex.components
pandas.TimedeltaIndex.days propertyTimedeltaIndex.days Number of days for each element.
pandas.reference.api.pandas.timedeltaindex.days
pandas.TimedeltaIndex.floor TimedeltaIndex.floor(*args, **kwargs)[source] Perform floor operation on the data to the specified freq. Parameters freq:str or Offset The frequency level to floor the index to. Must be a fixed frequency like ‘S’ (second) not ‘ME’ (month end). See frequency aliases for a list of possible freq values. ambiguous:‘infer’, bool-ndarray, ‘NaT’, default ‘raise’ Only relevant for DatetimeIndex: ‘infer’ will attempt to infer fall dst-transition hours based on order bool-ndarray where True signifies a DST time, False designates a non-DST time (note that this flag is only applicable for ambiguous times) ‘NaT’ will return NaT where there are ambiguous times ‘raise’ will raise an AmbiguousTimeError if there are ambiguous times. nonexistent:‘shift_forward’, ‘shift_backward’, ‘NaT’, timedelta, default ‘raise’ A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. ‘shift_forward’ will shift the nonexistent time forward to the closest existing time ‘shift_backward’ will shift the nonexistent time backward to the closest existing time ‘NaT’ will return NaT where there are nonexistent times timedelta objects will shift nonexistent times by the timedelta ‘raise’ will raise an NonExistentTimeError if there are nonexistent times. Returns DatetimeIndex, TimedeltaIndex, or Series Index of the same type for a DatetimeIndex or TimedeltaIndex, or a Series with the same index for a Series. Raises ValueError if the freq cannot be converted. Notes If the timestamps have a timezone, flooring will take place relative to the local (“wall”) time and re-localized to the same timezone. When flooring near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples DatetimeIndex >>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min') >>> rng DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00', '2018-01-01 12:01:00'], dtype='datetime64[ns]', freq='T') >>> rng.floor('H') DatetimeIndex(['2018-01-01 11:00:00', '2018-01-01 12:00:00', '2018-01-01 12:00:00'], dtype='datetime64[ns]', freq=None) Series >>> pd.Series(rng).dt.floor("H") 0 2018-01-01 11:00:00 1 2018-01-01 12:00:00 2 2018-01-01 12:00:00 dtype: datetime64[ns] When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized. >>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam") >>> rng_tz.floor("2H", ambiguous=False) DatetimeIndex(['2021-10-31 02:00:00+01:00'], dtype='datetime64[ns, Europe/Amsterdam]', freq=None) >>> rng_tz.floor("2H", ambiguous=True) DatetimeIndex(['2021-10-31 02:00:00+02:00'], dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
pandas.reference.api.pandas.timedeltaindex.floor
pandas.TimedeltaIndex.inferred_freq TimedeltaIndex.inferred_freq Tries to return a string representing a frequency guess, generated by infer_freq. Returns None if it can’t autodetect the frequency.
pandas.reference.api.pandas.timedeltaindex.inferred_freq
pandas.TimedeltaIndex.mean TimedeltaIndex.mean(*args, **kwargs)[source] Return the mean value of the Array. New in version 0.25.0. Parameters skipna:bool, default True Whether to ignore any NaT elements. axis:int, optional, default 0 Returns scalar Timestamp or Timedelta. See also numpy.ndarray.mean Returns the average of array elements along a given axis. Series.mean Return the mean value in a Series. Notes mean is only defined for Datetime and Timedelta dtypes, not for Period.
pandas.reference.api.pandas.timedeltaindex.mean
pandas.TimedeltaIndex.microseconds propertyTimedeltaIndex.microseconds Number of microseconds (>= 0 and less than 1 second) for each element.
pandas.reference.api.pandas.timedeltaindex.microseconds
pandas.TimedeltaIndex.nanoseconds propertyTimedeltaIndex.nanoseconds Number of nanoseconds (>= 0 and less than 1 microsecond) for each element.
pandas.reference.api.pandas.timedeltaindex.nanoseconds
pandas.TimedeltaIndex.round TimedeltaIndex.round(*args, **kwargs)[source] Perform round operation on the data to the specified freq. Parameters freq:str or Offset The frequency level to round the index to. Must be a fixed frequency like ‘S’ (second) not ‘ME’ (month end). See frequency aliases for a list of possible freq values. ambiguous:‘infer’, bool-ndarray, ‘NaT’, default ‘raise’ Only relevant for DatetimeIndex: ‘infer’ will attempt to infer fall dst-transition hours based on order bool-ndarray where True signifies a DST time, False designates a non-DST time (note that this flag is only applicable for ambiguous times) ‘NaT’ will return NaT where there are ambiguous times ‘raise’ will raise an AmbiguousTimeError if there are ambiguous times. nonexistent:‘shift_forward’, ‘shift_backward’, ‘NaT’, timedelta, default ‘raise’ A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. ‘shift_forward’ will shift the nonexistent time forward to the closest existing time ‘shift_backward’ will shift the nonexistent time backward to the closest existing time ‘NaT’ will return NaT where there are nonexistent times timedelta objects will shift nonexistent times by the timedelta ‘raise’ will raise an NonExistentTimeError if there are nonexistent times. Returns DatetimeIndex, TimedeltaIndex, or Series Index of the same type for a DatetimeIndex or TimedeltaIndex, or a Series with the same index for a Series. Raises ValueError if the freq cannot be converted. Notes If the timestamps have a timezone, rounding will take place relative to the local (“wall”) time and re-localized to the same timezone. When rounding near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples DatetimeIndex >>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min') >>> rng DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00', '2018-01-01 12:01:00'], dtype='datetime64[ns]', freq='T') >>> rng.round('H') DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00', '2018-01-01 12:00:00'], dtype='datetime64[ns]', freq=None) Series >>> pd.Series(rng).dt.round("H") 0 2018-01-01 12:00:00 1 2018-01-01 12:00:00 2 2018-01-01 12:00:00 dtype: datetime64[ns] When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized. >>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam") >>> rng_tz.floor("2H", ambiguous=False) DatetimeIndex(['2021-10-31 02:00:00+01:00'], dtype='datetime64[ns, Europe/Amsterdam]', freq=None) >>> rng_tz.floor("2H", ambiguous=True) DatetimeIndex(['2021-10-31 02:00:00+02:00'], dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
pandas.reference.api.pandas.timedeltaindex.round
pandas.TimedeltaIndex.seconds propertyTimedeltaIndex.seconds Number of seconds (>= 0 and less than 1 day) for each element.
pandas.reference.api.pandas.timedeltaindex.seconds
pandas.TimedeltaIndex.to_frame TimedeltaIndex.to_frame(index=True, name=NoDefault.no_default)[source] Create a DataFrame with a column containing the Index. Parameters index:bool, default True Set the index of the returned DataFrame as the original Index. name:object, default None The passed name should substitute for the index name (if it has one). Returns DataFrame DataFrame containing the original Index data. See also Index.to_series Convert an Index to a Series. Series.to_frame Convert Series to DataFrame. Examples >>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal') >>> idx.to_frame() animal animal Ant Ant Bear Bear Cow Cow By default, the original Index is reused. To enforce a new Index: >>> idx.to_frame(index=False) animal 0 Ant 1 Bear 2 Cow To override the name of the resulting column, specify name: >>> idx.to_frame(index=False, name='zoo') zoo 0 Ant 1 Bear 2 Cow
pandas.reference.api.pandas.timedeltaindex.to_frame
pandas.TimedeltaIndex.to_pytimedelta TimedeltaIndex.to_pytimedelta(*args, **kwargs)[source] Return Timedelta Array/Index as object ndarray of datetime.timedelta objects. Returns timedeltas:ndarray[object]
pandas.reference.api.pandas.timedeltaindex.to_pytimedelta
pandas.TimedeltaIndex.to_series TimedeltaIndex.to_series(index=None, name=None)[source] Create a Series with both index and values equal to the index keys. Useful with map for returning an indexer based on an index. Parameters index:Index, optional Index of resulting Series. If None, defaults to original index. name:str, optional Name of resulting Series. If None, defaults to name of original index. Returns Series The dtype will be based on the type of the Index values. See also Index.to_frame Convert an Index to a DataFrame. Series.to_frame Convert Series to DataFrame. Examples >>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal') By default, the original Index and original name is reused. >>> idx.to_series() animal Ant Ant Bear Bear Cow Cow Name: animal, dtype: object To enforce a new Index, specify new labels to index: >>> idx.to_series(index=[0, 1, 2]) 0 Ant 1 Bear 2 Cow Name: animal, dtype: object To override the name of the resulting column, specify name: >>> idx.to_series(name='zoo') animal Ant Ant Bear Bear Cow Cow Name: zoo, dtype: object
pandas.reference.api.pandas.timedeltaindex.to_series
pandas.Timestamp classpandas.Timestamp(ts_input=<object object>, freq=None, tz=None, unit=None, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None, nanosecond=None, tzinfo=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. freq:str, DateOffset Offset which Timestamp will have. tz:str, 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 ‘D’, ‘h’, ‘m’, ‘s’, ‘ms’, ‘us’, and ‘ns’. For example, ‘s’ means seconds and ‘ms’ means milliseconds. year, month, day:int hour, minute, second, microsecond:int, optional, default 0 nanosecond:int, optional, default 0 tzinfo:datetime.tzinfo, optional, default None 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. New in version 1.1.0. 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 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 in nanoseconds. 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. freqstr Return the total number of days in the month. is_leap_year Return True if year is a leap year. is_month_end Return True if date is last day of month. is_month_start Return True if date is first day of month. is_quarter_end Return True if date is last day of the quarter. is_quarter_start Return True if date is 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. quarter Return the quarter of the year. tz Alias for tzinfo. week Return the week number of the year. weekofyear Return the week number of the year. day fold freq hour microsecond minute month nanosecond second tzinfo value year Methods 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 date, time into datetime with same date and time fields. ctime Return ctime() style string. date Return date object with same year, month and day. day_name Return the day name of the Timestamp with specified locale. dst Return self.tzinfo.dst(self). 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 datetime.isoformat() output fromordinal(ordinal[, freq, tz]) Passed an ordinal, translate and convert to a ts. fromtimestamp(ts) Transform timestamp[, tz] to tz's local time from POSIX timestamp. isocalendar Return a 3-tuple containing ISO year, week number, and weekday. isoformat Return the time formatted according to ISO 8610. isoweekday() Return the day of the week represented by the date. month_name 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 string representing the given POSIX timestamp controlled by an explicit format string. strptime(string, format) Function is not implemented. 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 'ns' precision. to_julian_date() Convert TimeStamp to a Julian Date. to_numpy Convert the Timestamp to a NumPy datetime64. to_period Return an period of which this timestamp is an observation. to_pydatetime Convert a Timestamp object to a native Python datetime object. today(cls[, 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]) Convert naive Timestamp to local time zone, or remove timezone from timezone-aware Timestamp. tzname Return self.tzinfo.tzname(self). utcfromtimestamp(ts) Construct a naive UTC datetime from a POSIX timestamp. utcnow() Return a new Timestamp representing UTC day and time. utcoffset Return self.tzinfo.utcoffset(self). utctimetuple Return UTC time tuple, compatible with time.localtime(). weekday() Return the day of the week represented by the date.
pandas.reference.api.pandas.timestamp
pandas.Timestamp.asm8 Timestamp.asm8 Return numpy datetime64 format in nanoseconds. Examples >>> ts = pd.Timestamp(2020, 3, 14, 15) >>> ts.asm8 numpy.datetime64('2020-03-14T15:00:00.000000000')
pandas.reference.api.pandas.timestamp.asm8
pandas.Timestamp.astimezone Timestamp.astimezone(tz) Convert timezone-aware Timestamp to another time zone. Parameters tz:str, pytz.timezone, dateutil.tz.tzfile or None Time zone for time which Timestamp will be converted to. None will remove timezone holding UTC time. Returns converted:Timestamp Raises TypeError If Timestamp is tz-naive. Examples Create a timestamp object with UTC timezone: >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651', tz='UTC') >>> ts Timestamp('2020-03-14 15:32:52.192548651+0000', tz='UTC') Change to Tokyo timezone: >>> ts.tz_convert(tz='Asia/Tokyo') Timestamp('2020-03-15 00:32:52.192548651+0900', tz='Asia/Tokyo') Can also use astimezone: >>> ts.astimezone(tz='Asia/Tokyo') Timestamp('2020-03-15 00:32:52.192548651+0900', tz='Asia/Tokyo') Analogous for pd.NaT: >>> pd.NaT.tz_convert(tz='Asia/Tokyo') NaT
pandas.reference.api.pandas.timestamp.astimezone
pandas.Timestamp.ceil Timestamp.ceil(freq, ambiguous='raise', nonexistent='raise') Return a new Timestamp ceiled to this resolution. Parameters freq:str Frequency string indicating the ceiling resolution. ambiguous:bool or {‘raise’, ‘NaT’}, default ‘raise’ The behavior is as follows: bool contains flags to determine if time is dst or not (note that this flag is only applicable for ambiguous fall dst dates). ‘NaT’ will return NaT for an ambiguous time. ‘raise’ will raise an AmbiguousTimeError for an ambiguous time. nonexistent:{‘raise’, ‘shift_forward’, ‘shift_backward, ‘NaT’, timedelta}, default ‘raise’ A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. ‘shift_forward’ will shift the nonexistent time forward to the closest existing time. ‘shift_backward’ will shift the nonexistent time backward to the closest existing time. ‘NaT’ will return NaT where there are nonexistent times. timedelta objects will shift nonexistent times by the timedelta. ‘raise’ will raise an NonExistentTimeError if there are nonexistent times. Raises ValueError if the freq cannot be converted. Notes If the Timestamp has a timezone, ceiling will take place relative to the local (“wall”) time and re-localized to the same timezone. When ceiling near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples Create a timestamp object: >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') A timestamp can be ceiled using multiple frequency units: >>> ts.ceil(freq='H') # hour Timestamp('2020-03-14 16:00:00') >>> ts.ceil(freq='T') # minute Timestamp('2020-03-14 15:33:00') >>> ts.ceil(freq='S') # seconds Timestamp('2020-03-14 15:32:53') >>> ts.ceil(freq='U') # microseconds Timestamp('2020-03-14 15:32:52.192549') freq can also be a multiple of a single unit, like ‘5T’ (i.e. 5 minutes): >>> ts.ceil(freq='5T') Timestamp('2020-03-14 15:35:00') or a combination of multiple units, like ‘1H30T’ (i.e. 1 hour and 30 minutes): >>> ts.ceil(freq='1H30T') Timestamp('2020-03-14 16:30:00') Analogous for pd.NaT: >>> pd.NaT.ceil() NaT When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized. >>> ts_tz = pd.Timestamp("2021-10-31 01:30:00").tz_localize("Europe/Amsterdam") >>> ts_tz.ceil("H", ambiguous=False) Timestamp('2021-10-31 02:00:00+0100', tz='Europe/Amsterdam') >>> ts_tz.ceil("H", ambiguous=True) Timestamp('2021-10-31 02:00:00+0200', tz='Europe/Amsterdam')
pandas.reference.api.pandas.timestamp.ceil
pandas.Timestamp.combine classmethodTimestamp.combine(date, time) Combine date, time into datetime with same date and time fields. Examples >>> from datetime import date, time >>> pd.Timestamp.combine(date(2020, 3, 14), time(15, 30, 15)) Timestamp('2020-03-14 15:30:15')
pandas.reference.api.pandas.timestamp.combine
pandas.Timestamp.ctime Timestamp.ctime() Return ctime() style string.
pandas.reference.api.pandas.timestamp.ctime
pandas.Timestamp.date Timestamp.date() Return date object with same year, month and day.
pandas.reference.api.pandas.timestamp.date
pandas.Timestamp.day Timestamp.day
pandas.reference.api.pandas.timestamp.day
pandas.Timestamp.day_name Timestamp.day_name() Return the day name of the Timestamp with specified locale. Parameters locale:str, default None (English locale) Locale determining the language in which to return the day name. Returns str Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') >>> ts.day_name() 'Saturday' Analogous for pd.NaT: >>> pd.NaT.day_name() nan
pandas.reference.api.pandas.timestamp.day_name
pandas.Timestamp.day_of_week Timestamp.day_of_week Return day of the week. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.day_of_week 5
pandas.reference.api.pandas.timestamp.day_of_week
pandas.Timestamp.day_of_year Timestamp.day_of_year Return the day of the year. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.day_of_year 74
pandas.reference.api.pandas.timestamp.day_of_year
pandas.Timestamp.dayofweek Timestamp.dayofweek Return day of the week. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.day_of_week 5
pandas.reference.api.pandas.timestamp.dayofweek
pandas.Timestamp.dayofyear Timestamp.dayofyear Return the day of the year. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.day_of_year 74
pandas.reference.api.pandas.timestamp.dayofyear
pandas.Timestamp.days_in_month Timestamp.days_in_month Return the number of days in the month. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.days_in_month 31
pandas.reference.api.pandas.timestamp.days_in_month
pandas.Timestamp.daysinmonth Timestamp.daysinmonth Return the number of days in the month. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.days_in_month 31
pandas.reference.api.pandas.timestamp.daysinmonth
pandas.Timestamp.dst Timestamp.dst() Return self.tzinfo.dst(self).
pandas.reference.api.pandas.timestamp.dst
pandas.Timestamp.floor Timestamp.floor(freq, ambiguous='raise', nonexistent='raise') Return a new Timestamp floored to this resolution. Parameters freq:str Frequency string indicating the flooring resolution. ambiguous:bool or {‘raise’, ‘NaT’}, default ‘raise’ The behavior is as follows: bool contains flags to determine if time is dst or not (note that this flag is only applicable for ambiguous fall dst dates). ‘NaT’ will return NaT for an ambiguous time. ‘raise’ will raise an AmbiguousTimeError for an ambiguous time. nonexistent:{‘raise’, ‘shift_forward’, ‘shift_backward, ‘NaT’, timedelta}, default ‘raise’ A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. ‘shift_forward’ will shift the nonexistent time forward to the closest existing time. ‘shift_backward’ will shift the nonexistent time backward to the closest existing time. ‘NaT’ will return NaT where there are nonexistent times. timedelta objects will shift nonexistent times by the timedelta. ‘raise’ will raise an NonExistentTimeError if there are nonexistent times. Raises ValueError if the freq cannot be converted. Notes If the Timestamp has a timezone, flooring will take place relative to the local (“wall”) time and re-localized to the same timezone. When flooring near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples Create a timestamp object: >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') A timestamp can be floored using multiple frequency units: >>> ts.floor(freq='H') # hour Timestamp('2020-03-14 15:00:00') >>> ts.floor(freq='T') # minute Timestamp('2020-03-14 15:32:00') >>> ts.floor(freq='S') # seconds Timestamp('2020-03-14 15:32:52') >>> ts.floor(freq='N') # nanoseconds Timestamp('2020-03-14 15:32:52.192548651') freq can also be a multiple of a single unit, like ‘5T’ (i.e. 5 minutes): >>> ts.floor(freq='5T') Timestamp('2020-03-14 15:30:00') or a combination of multiple units, like ‘1H30T’ (i.e. 1 hour and 30 minutes): >>> ts.floor(freq='1H30T') Timestamp('2020-03-14 15:00:00') Analogous for pd.NaT: >>> pd.NaT.floor() NaT When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized. >>> ts_tz = pd.Timestamp("2021-10-31 03:30:00").tz_localize("Europe/Amsterdam") >>> ts_tz.floor("2H", ambiguous=False) Timestamp('2021-10-31 02:00:00+0100', tz='Europe/Amsterdam') >>> ts_tz.floor("2H", ambiguous=True) Timestamp('2021-10-31 02:00:00+0200', tz='Europe/Amsterdam')
pandas.reference.api.pandas.timestamp.floor
pandas.Timestamp.fold Timestamp.fold
pandas.reference.api.pandas.timestamp.fold
pandas.Timestamp.freq Timestamp.freq
pandas.reference.api.pandas.timestamp.freq
pandas.Timestamp.freqstr propertyTimestamp.freqstr Return the total number of days in the month.
pandas.reference.api.pandas.timestamp.freqstr
pandas.Timestamp.fromisocalendar Timestamp.fromisocalendar() int, int, int -> Construct a date from the ISO year, week number and weekday. This is the inverse of the date.isocalendar() function
pandas.reference.api.pandas.timestamp.fromisocalendar
pandas.Timestamp.fromisoformat Timestamp.fromisoformat() string -> datetime from datetime.isoformat() output
pandas.reference.api.pandas.timestamp.fromisoformat
pandas.Timestamp.fromordinal classmethodTimestamp.fromordinal(ordinal, freq=None, tz=None) Passed an ordinal, translate and convert to a ts. Note: by definition there cannot be any tz info on the ordinal itself. Parameters ordinal:int Date corresponding to a proleptic Gregorian ordinal. freq:str, DateOffset Offset to apply to the Timestamp. tz:str, pytz.timezone, dateutil.tz.tzfile or None Time zone for the Timestamp. Examples >>> pd.Timestamp.fromordinal(737425) Timestamp('2020-01-01 00:00:00')
pandas.reference.api.pandas.timestamp.fromordinal
pandas.Timestamp.fromtimestamp classmethodTimestamp.fromtimestamp(ts) Transform timestamp[, tz] to tz’s local time from POSIX timestamp. Examples >>> pd.Timestamp.fromtimestamp(1584199972) Timestamp('2020-03-14 15:32:52') Note that the output may change depending on your local time.
pandas.reference.api.pandas.timestamp.fromtimestamp
pandas.Timestamp.hour Timestamp.hour
pandas.reference.api.pandas.timestamp.hour
pandas.Timestamp.is_leap_year Timestamp.is_leap_year Return True if year is a leap year. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.is_leap_year True
pandas.reference.api.pandas.timestamp.is_leap_year
pandas.Timestamp.is_month_end Timestamp.is_month_end Return True if date is last day of month. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.is_month_end False >>> ts = pd.Timestamp(2020, 12, 31) >>> ts.is_month_end True
pandas.reference.api.pandas.timestamp.is_month_end
pandas.Timestamp.is_month_start Timestamp.is_month_start Return True if date is first day of month. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.is_month_start False >>> ts = pd.Timestamp(2020, 1, 1) >>> ts.is_month_start True
pandas.reference.api.pandas.timestamp.is_month_start
pandas.Timestamp.is_quarter_end Timestamp.is_quarter_end Return True if date is last day of the quarter. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.is_quarter_end False >>> ts = pd.Timestamp(2020, 3, 31) >>> ts.is_quarter_end True
pandas.reference.api.pandas.timestamp.is_quarter_end
pandas.Timestamp.is_quarter_start Timestamp.is_quarter_start Return True if date is first day of the quarter. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.is_quarter_start False >>> ts = pd.Timestamp(2020, 4, 1) >>> ts.is_quarter_start True
pandas.reference.api.pandas.timestamp.is_quarter_start
pandas.Timestamp.is_year_end Timestamp.is_year_end Return True if date is last day of the year. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.is_year_end False >>> ts = pd.Timestamp(2020, 12, 31) >>> ts.is_year_end True
pandas.reference.api.pandas.timestamp.is_year_end
pandas.Timestamp.is_year_start Timestamp.is_year_start Return True if date is first day of the year. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.is_year_start False >>> ts = pd.Timestamp(2020, 1, 1) >>> ts.is_year_start True
pandas.reference.api.pandas.timestamp.is_year_start
pandas.Timestamp.isocalendar Timestamp.isocalendar() Return a 3-tuple containing ISO year, week number, and weekday.
pandas.reference.api.pandas.timestamp.isocalendar
pandas.Timestamp.isoformat Timestamp.isoformat() Return the time formatted according to ISO 8610. The full format looks like ‘YYYY-MM-DD HH:MM:SS.mmmmmmnnn’. By default, the fractional part is omitted if self.microsecond == 0 and self.nanosecond == 0. If self.tzinfo is not None, the UTC offset is also attached, giving giving a full format of ‘YYYY-MM-DD HH:MM:SS.mmmmmmnnn+HH:MM’. Parameters sep:str, default ‘T’ String used as the separator between the date and time. timespec:str, default ‘auto’ Specifies the number of additional terms of the time to include. The valid values are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘microseconds’, and ‘nanoseconds’. Returns str Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') >>> ts.isoformat() '2020-03-14T15:32:52.192548651' >>> ts.isoformat(timespec='microseconds') '2020-03-14T15:32:52.192548'
pandas.reference.api.pandas.timestamp.isoformat
pandas.Timestamp.isoweekday Timestamp.isoweekday() Return the day of the week represented by the date. Monday == 1 … Sunday == 7.
pandas.reference.api.pandas.timestamp.isoweekday
pandas.Timestamp.max Timestamp.max=Timestamp('2262-04-11 23:47:16.854775807')
pandas.reference.api.pandas.timestamp.max
pandas.Timestamp.microsecond Timestamp.microsecond
pandas.reference.api.pandas.timestamp.microsecond
pandas.Timestamp.min Timestamp.min=Timestamp('1677-09-21 00:12:43.145224193')
pandas.reference.api.pandas.timestamp.min
pandas.Timestamp.minute Timestamp.minute
pandas.reference.api.pandas.timestamp.minute
pandas.Timestamp.month Timestamp.month
pandas.reference.api.pandas.timestamp.month
pandas.Timestamp.month_name Timestamp.month_name() Return the month name of the Timestamp with specified locale. Parameters locale:str, default None (English locale) Locale determining the language in which to return the month name. Returns str Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') >>> ts.month_name() 'March' Analogous for pd.NaT: >>> pd.NaT.month_name() nan
pandas.reference.api.pandas.timestamp.month_name
pandas.Timestamp.nanosecond Timestamp.nanosecond
pandas.reference.api.pandas.timestamp.nanosecond
pandas.Timestamp.normalize Timestamp.normalize() Normalize Timestamp to midnight, preserving tz information. Examples >>> ts = pd.Timestamp(2020, 3, 14, 15, 30) >>> ts.normalize() Timestamp('2020-03-14 00:00:00')
pandas.reference.api.pandas.timestamp.normalize
pandas.Timestamp.now classmethodTimestamp.now(tz=None) Return new Timestamp object representing current time local to tz. Parameters tz:str or timezone object, default None Timezone to localize to. Examples >>> pd.Timestamp.now() Timestamp('2020-11-16 22:06:16.378782') Analogous for pd.NaT: >>> pd.NaT.now() NaT
pandas.reference.api.pandas.timestamp.now
pandas.Timestamp.quarter Timestamp.quarter Return the quarter of the year. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.quarter 1
pandas.reference.api.pandas.timestamp.quarter
pandas.Timestamp.replace Timestamp.replace(year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None, nanosecond=None, tzinfo=<class 'object'>, fold=None) Implements datetime.replace, handles nanoseconds. Parameters year:int, optional month:int, optional day:int, optional hour:int, optional minute:int, optional second:int, optional microsecond:int, optional nanosecond:int, optional tzinfo:tz-convertible, optional fold:int, optional Returns Timestamp with fields replaced Examples Create a timestamp object: >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651', tz='UTC') >>> ts Timestamp('2020-03-14 15:32:52.192548651+0000', tz='UTC') Replace year and the hour: >>> ts.replace(year=1999, hour=10) Timestamp('1999-03-14 10:32:52.192548651+0000', tz='UTC') Replace timezone (not a conversion): >>> import pytz >>> ts.replace(tzinfo=pytz.timezone('US/Pacific')) Timestamp('2020-03-14 15:32:52.192548651-0700', tz='US/Pacific') Analogous for pd.NaT: >>> pd.NaT.replace(tzinfo=pytz.timezone('US/Pacific')) NaT
pandas.reference.api.pandas.timestamp.replace
pandas.Timestamp.resolution Timestamp.resolution=Timedelta('0 days 00:00:00.000000001')
pandas.reference.api.pandas.timestamp.resolution
pandas.Timestamp.round Timestamp.round(freq, ambiguous='raise', nonexistent='raise') Round the Timestamp to the specified resolution. Parameters freq:str Frequency string indicating the rounding resolution. ambiguous:bool or {‘raise’, ‘NaT’}, default ‘raise’ The behavior is as follows: bool contains flags to determine if time is dst or not (note that this flag is only applicable for ambiguous fall dst dates). ‘NaT’ will return NaT for an ambiguous time. ‘raise’ will raise an AmbiguousTimeError for an ambiguous time. nonexistent:{‘raise’, ‘shift_forward’, ‘shift_backward, ‘NaT’, timedelta}, default ‘raise’ A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. ‘shift_forward’ will shift the nonexistent time forward to the closest existing time. ‘shift_backward’ will shift the nonexistent time backward to the closest existing time. ‘NaT’ will return NaT where there are nonexistent times. timedelta objects will shift nonexistent times by the timedelta. ‘raise’ will raise an NonExistentTimeError if there are nonexistent times. Returns a new Timestamp rounded to the given resolution of freq Raises ValueError if the freq cannot be converted Notes If the Timestamp has a timezone, rounding will take place relative to the local (“wall”) time and re-localized to the same timezone. When rounding near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples Create a timestamp object: >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') A timestamp can be rounded using multiple frequency units: >>> ts.round(freq='H') # hour Timestamp('2020-03-14 16:00:00') >>> ts.round(freq='T') # minute Timestamp('2020-03-14 15:33:00') >>> ts.round(freq='S') # seconds Timestamp('2020-03-14 15:32:52') >>> ts.round(freq='L') # milliseconds Timestamp('2020-03-14 15:32:52.193000') freq can also be a multiple of a single unit, like ‘5T’ (i.e. 5 minutes): >>> ts.round(freq='5T') Timestamp('2020-03-14 15:35:00') or a combination of multiple units, like ‘1H30T’ (i.e. 1 hour and 30 minutes): >>> ts.round(freq='1H30T') Timestamp('2020-03-14 15:00:00') Analogous for pd.NaT: >>> pd.NaT.round() NaT When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized. >>> ts_tz = pd.Timestamp("2021-10-31 01:30:00").tz_localize("Europe/Amsterdam") >>> ts_tz.round("H", ambiguous=False) Timestamp('2021-10-31 02:00:00+0100', tz='Europe/Amsterdam') >>> ts_tz.round("H", ambiguous=True) Timestamp('2021-10-31 02:00:00+0200', tz='Europe/Amsterdam')
pandas.reference.api.pandas.timestamp.round
pandas.Timestamp.second Timestamp.second
pandas.reference.api.pandas.timestamp.second
pandas.Timestamp.strftime Timestamp.strftime(format) Return a string representing the given POSIX timestamp controlled by an explicit format string. Parameters format:str Format string to convert Timestamp to string. See strftime documentation for more information on the format string: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior. Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') >>> ts.strftime('%Y-%m-%d %X') '2020-03-14 15:32:52'
pandas.reference.api.pandas.timestamp.strftime
pandas.Timestamp.strptime classmethodTimestamp.strptime(string, format) Function is not implemented. Use pd.to_datetime().
pandas.reference.api.pandas.timestamp.strptime
pandas.Timestamp.time Timestamp.time() Return time object with same time but with tzinfo=None.
pandas.reference.api.pandas.timestamp.time
pandas.Timestamp.timestamp Timestamp.timestamp() Return POSIX timestamp as float. Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548') >>> ts.timestamp() 1584199972.192548
pandas.reference.api.pandas.timestamp.timestamp
pandas.Timestamp.timetuple Timestamp.timetuple() Return time tuple, compatible with time.localtime().
pandas.reference.api.pandas.timestamp.timetuple
pandas.Timestamp.timetz Timestamp.timetz() Return time object with same time and tzinfo.
pandas.reference.api.pandas.timestamp.timetz
pandas.Timestamp.to_datetime64 Timestamp.to_datetime64() Return a numpy.datetime64 object with ‘ns’ precision.
pandas.reference.api.pandas.timestamp.to_datetime64
pandas.Timestamp.to_julian_date Timestamp.to_julian_date() Convert TimeStamp to a Julian Date. 0 Julian date is noon January 1, 4713 BC. Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52') >>> ts.to_julian_date() 2458923.147824074
pandas.reference.api.pandas.timestamp.to_julian_date
pandas.Timestamp.to_numpy Timestamp.to_numpy() Convert the Timestamp to a NumPy datetime64. New in version 0.25.0. This is an alias method for Timestamp.to_datetime64(). The dtype and copy parameters are available here only for compatibility. Their values will not affect the return value. Returns numpy.datetime64 See also DatetimeIndex.to_numpy Similar method for DatetimeIndex. Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') >>> ts.to_numpy() numpy.datetime64('2020-03-14T15:32:52.192548651') Analogous for pd.NaT: >>> pd.NaT.to_numpy() numpy.datetime64('NaT')
pandas.reference.api.pandas.timestamp.to_numpy
pandas.Timestamp.to_period Timestamp.to_period() Return an period of which this timestamp is an observation. Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') >>> # Year end frequency >>> ts.to_period(freq='Y') Period('2020', 'A-DEC') >>> # Month end frequency >>> ts.to_period(freq='M') Period('2020-03', 'M') >>> # Weekly frequency >>> ts.to_period(freq='W') Period('2020-03-09/2020-03-15', 'W-SUN') >>> # Quarter end frequency >>> ts.to_period(freq='Q') Period('2020Q1', 'Q-DEC')
pandas.reference.api.pandas.timestamp.to_period
pandas.Timestamp.to_pydatetime Timestamp.to_pydatetime() Convert a Timestamp object to a native Python datetime object. If warn=True, issue a warning if nanoseconds is nonzero. Examples >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548') >>> ts.to_pydatetime() datetime.datetime(2020, 3, 14, 15, 32, 52, 192548) Analogous for pd.NaT: >>> pd.NaT.to_pydatetime() NaT
pandas.reference.api.pandas.timestamp.to_pydatetime
pandas.Timestamp.today classmethodTimestamp.today(cls, tz=None) Return the current time in the local timezone. This differs from datetime.today() in that it can be localized to a passed timezone. Parameters tz:str or timezone object, default None Timezone to localize to. Examples >>> pd.Timestamp.today() Timestamp('2020-11-16 22:37:39.969883') Analogous for pd.NaT: >>> pd.NaT.today() NaT
pandas.reference.api.pandas.timestamp.today
pandas.Timestamp.toordinal Timestamp.toordinal() Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.
pandas.reference.api.pandas.timestamp.toordinal
pandas.Timestamp.tz propertyTimestamp.tz Alias for tzinfo. Examples >>> ts = pd.Timestamp(1584226800, unit='s', tz='Europe/Stockholm') >>> ts.tz <DstTzInfo 'Europe/Stockholm' CET+1:00:00 STD>
pandas.reference.api.pandas.timestamp.tz
pandas.Timestamp.tz_convert Timestamp.tz_convert(tz) Convert timezone-aware Timestamp to another time zone. Parameters tz:str, pytz.timezone, dateutil.tz.tzfile or None Time zone for time which Timestamp will be converted to. None will remove timezone holding UTC time. Returns converted:Timestamp Raises TypeError If Timestamp is tz-naive. Examples Create a timestamp object with UTC timezone: >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651', tz='UTC') >>> ts Timestamp('2020-03-14 15:32:52.192548651+0000', tz='UTC') Change to Tokyo timezone: >>> ts.tz_convert(tz='Asia/Tokyo') Timestamp('2020-03-15 00:32:52.192548651+0900', tz='Asia/Tokyo') Can also use astimezone: >>> ts.astimezone(tz='Asia/Tokyo') Timestamp('2020-03-15 00:32:52.192548651+0900', tz='Asia/Tokyo') Analogous for pd.NaT: >>> pd.NaT.tz_convert(tz='Asia/Tokyo') NaT
pandas.reference.api.pandas.timestamp.tz_convert
pandas.Timestamp.tz_localize Timestamp.tz_localize(tz, ambiguous='raise', nonexistent='raise') Convert naive Timestamp to local time zone, or remove timezone from timezone-aware Timestamp. Parameters tz:str, pytz.timezone, dateutil.tz.tzfile or None Time zone for time which Timestamp will be converted to. None will remove timezone holding local time. ambiguous:bool, ‘NaT’, default ‘raise’ When clocks moved backward due to DST, ambiguous times may arise. For example in Central European Time (UTC+01), when going from 03:00 DST to 02:00 non-DST, 02:30:00 local time occurs both at 00:30:00 UTC and at 01:30:00 UTC. In such a situation, the ambiguous parameter dictates how ambiguous times should be handled. The behavior is as follows: bool contains flags to determine if time is dst or not (note that this flag is only applicable for ambiguous fall dst dates). ‘NaT’ will return NaT for an ambiguous time. ‘raise’ will raise an AmbiguousTimeError for an ambiguous time. nonexistent:‘shift_forward’, ‘shift_backward, ‘NaT’, timedelta, default ‘raise’ A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. The behavior is as follows: ‘shift_forward’ will shift the nonexistent time forward to the closest existing time. ‘shift_backward’ will shift the nonexistent time backward to the closest existing time. ‘NaT’ will return NaT where there are nonexistent times. timedelta objects will shift nonexistent times by the timedelta. ‘raise’ will raise an NonExistentTimeError if there are nonexistent times. Returns localized:Timestamp Raises TypeError If the Timestamp is tz-aware and tz is not None. Examples Create a naive timestamp object: >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') >>> ts Timestamp('2020-03-14 15:32:52.192548651') Add ‘Europe/Stockholm’ as timezone: >>> ts.tz_localize(tz='Europe/Stockholm') Timestamp('2020-03-14 15:32:52.192548651+0100', tz='Europe/Stockholm') Analogous for pd.NaT: >>> pd.NaT.tz_localize() NaT
pandas.reference.api.pandas.timestamp.tz_localize
pandas.Timestamp.tzinfo Timestamp.tzinfo
pandas.reference.api.pandas.timestamp.tzinfo
pandas.Timestamp.tzname Timestamp.tzname() Return self.tzinfo.tzname(self).
pandas.reference.api.pandas.timestamp.tzname
pandas.Timestamp.utcfromtimestamp classmethodTimestamp.utcfromtimestamp(ts) Construct a naive UTC datetime from a POSIX timestamp. Examples >>> pd.Timestamp.utcfromtimestamp(1584199972) Timestamp('2020-03-14 15:32:52')
pandas.reference.api.pandas.timestamp.utcfromtimestamp
pandas.Timestamp.utcnow classmethodTimestamp.utcnow() Return a new Timestamp representing UTC day and time. Examples >>> pd.Timestamp.utcnow() Timestamp('2020-11-16 22:50:18.092888+0000', tz='UTC')
pandas.reference.api.pandas.timestamp.utcnow
pandas.Timestamp.utcoffset Timestamp.utcoffset() Return self.tzinfo.utcoffset(self).
pandas.reference.api.pandas.timestamp.utcoffset
pandas.Timestamp.utctimetuple Timestamp.utctimetuple() Return UTC time tuple, compatible with time.localtime().
pandas.reference.api.pandas.timestamp.utctimetuple
pandas.Timestamp.value Timestamp.value
pandas.reference.api.pandas.timestamp.value
pandas.Timestamp.week Timestamp.week Return the week number of the year. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.week 11
pandas.reference.api.pandas.timestamp.week
pandas.Timestamp.weekday Timestamp.weekday() Return the day of the week represented by the date. Monday == 0 … Sunday == 6.
pandas.reference.api.pandas.timestamp.weekday
pandas.Timestamp.weekofyear Timestamp.weekofyear Return the week number of the year. Examples >>> ts = pd.Timestamp(2020, 3, 14) >>> ts.week 11
pandas.reference.api.pandas.timestamp.weekofyear