Pandas arrays — pandas 1.0.5 documentation (original) (raw)
NumPy cannot natively represent timezone-aware datetimes. Pandas supports this with the arrays.DatetimeArray extension array, which can hold timezone-naive or timezone-aware values.
Timestamp, a subclass of datetime.datetime, is pandas’ scalar type for timezone-naive or timezone-aware datetime data.
Methods¶
| Timestamp.astimezone(self, tz) | Convert tz-aware Timestamp to another time zone. |
|---|---|
| Timestamp.ceil(self, freq[, ambiguous, …]) | return a new Timestamp ceiled to this resolution. |
| Timestamp.combine(date, time) | date, time -> datetime with same date and time fields. |
| Timestamp.ctime() | Return ctime() style string. |
| Timestamp.date() | Return date object with same year, month and day. |
| Timestamp.day_name(self[, locale]) | Return the day name of the Timestamp with specified locale. |
| Timestamp.dst() | Return self.tzinfo.dst(self). |
| Timestamp.floor(self, freq[, ambiguous, …]) | return a new Timestamp floored to this resolution. |
| Timestamp.freq | |
| Timestamp.freqstr | Return the total number of days in the month. |
| Timestamp.fromordinal(ordinal[, freq, tz]) | Passed an ordinal, translate and convert to a ts. |
| Timestamp.fromtimestamp(ts) | timestamp[, tz] -> tz’s local time from POSIX timestamp. |
| Timestamp.isocalendar() | Return a 3-tuple containing ISO year, week number, and weekday. |
| Timestamp.isoformat(self[, sep]) | [sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. |
| Timestamp.isoweekday() | Return the day of the week represented by the date. |
| Timestamp.month_name(self[, locale]) | Return the month name of the Timestamp with specified locale. |
| Timestamp.normalize(self) | Normalize Timestamp to midnight, preserving tz information. |
| Timestamp.now([tz]) | Return new Timestamp object representing current time local to tz. |
| Timestamp.replace(self[, year, month, day, …]) | implements datetime.replace, handles nanoseconds. |
| Timestamp.round(self, freq[, ambiguous, …]) | Round the Timestamp to the specified resolution. |
| Timestamp.strftime() | format -> strftime() style string. |
| Timestamp.strptime(string, format) | Function is not implemented. |
| Timestamp.time() | Return time object with same time but with tzinfo=None. |
| Timestamp.timestamp() | Return POSIX timestamp as float. |
| Timestamp.timetuple() | Return time tuple, compatible with time.localtime(). |
| Timestamp.timetz() | Return time object with same time and tzinfo. |
| Timestamp.to_datetime64() | Return a numpy.datetime64 object with ‘ns’ precision. |
| Timestamp.to_numpy() | Convert the Timestamp to a NumPy datetime64. |
| Timestamp.to_julian_date(self) | Convert TimeStamp to a Julian Date. |
| Timestamp.to_period(self[, freq]) | Return an period of which this timestamp is an observation. |
| Timestamp.to_pydatetime() | Convert a Timestamp object to a native Python datetime object. |
| Timestamp.today(cls[, tz]) | Return the current time in the local timezone. |
| Timestamp.toordinal() | Return proleptic Gregorian ordinal. |
| Timestamp.tz_convert(self, tz) | Convert tz-aware Timestamp to another time zone. |
| Timestamp.tz_localize(self, tz[, ambiguous, …]) | Convert naive Timestamp to local time zone, or remove timezone from tz-aware Timestamp. |
| Timestamp.tzname() | Return self.tzinfo.tzname(self). |
| Timestamp.utcfromtimestamp(ts) | Construct a naive UTC datetime from a POSIX timestamp. |
| Timestamp.utcnow() | Return a new Timestamp representing UTC day and time. |
| Timestamp.utcoffset() | Return self.tzinfo.utcoffset(self). |
| Timestamp.utctimetuple() | Return UTC time tuple, compatible with time.localtime(). |
| Timestamp.weekday() | Return the day of the week represented by the date. |
A collection of timestamps may be stored in a arrays.DatetimeArray. For timezone-aware data, the .dtype of a DatetimeArray is aDatetimeTZDtype. For timezone-naive data, np.dtype("datetime64[ns]")is used.
If the data are tz-aware, then every value in the array must have the same timezone.
| arrays.DatetimeArray(values[, dtype, freq, copy]) | Pandas ExtensionArray for tz-naive or tz-aware datetime data. |
|---|
| DatetimeTZDtype([unit, tz]) | An ExtensionDtype for timezone-aware datetime data. |
|---|