On this page
pandas.arrays.DatetimeArray
class pandas.arrays.DatetimeArray(values, dtype=dtype('<M8[ns]'), freq=None, copy=False)[source]-
Pandas ExtensionArray for tz-naive or tz-aware datetime data.
New in version 0.24.0.
Warning
DatetimeArray is currently experimental, and its API may change without warning. In particular,
DatetimeArray.dtypeis expected to change to always be an instance of anExtensionDtypesubclass.Parameters: -
values : Series, Index, DatetimeArray, ndarray -
The datetime data.
For DatetimeArray
values(or a Series or Index boxing one),dtypeandfreqwill be extracted fromvalues, with precedence given to -
dtype : numpy.dtype or DatetimeTZDtype -
Note that the only NumPy dtype allowed is ‘datetime64[ns]’.
-
freq : str or Offset, optional -
copy : bool, default False -
Whether to copy the underlying array of values.
Attributes
asi8Integer representation of the values. dateReturns numpy array of python datetime.date objects (namely, the date part of Timestamps without timezone information). dayThe days of the datetime. dayofweekThe day of the week with Monday=0, Sunday=6. dayofyearThe ordinal day of the year. days_in_monthThe number of days in the month. daysinmonthThe number of days in the month. dtypeThe dtype for the DatetimeArray. freqReturn the frequency object if it is set, otherwise None. freqstrReturn the frequency object as a string if its set, otherwise None hourThe hours of the datetime. inferred_freqTryies to return a string representing a frequency guess, generated by infer_freq. is_leap_yearBoolean indicator if the date belongs to a leap year. is_month_endIndicates whether the date is the last day of the month. is_month_startIndicates whether the date is the first day of the month. is_normalizedReturns True if all of the dates are at midnight (“no time”) is_quarter_endIndicator for whether the date is the last day of a quarter. is_quarter_startIndicator for whether the date is the first day of a quarter. is_year_endIndicate whether the date is the last day of the year. is_year_startIndicate whether the date is the first day of a year. microsecondThe microseconds of the datetime. minuteThe minutes of the datetime. monthThe month as January=1, December=12. nanosecondThe nanoseconds of the datetime. nbytesThe number of bytes needed to store this object in memory. quarterThe quarter of the date. resolutionReturns day, hour, minute, second, millisecond or microsecond secondThe seconds of the datetime. shapeReturn a tuple of the array dimensions. sizeThe number of elements in this array. timeReturns numpy array of datetime.time. timetzReturns numpy array of datetime.time also containing timezone information. tzReturn timezone, if any. tzinfoAlias for tz attribute weekThe week ordinal of the year. weekdayThe day of the week with Monday=0, Sunday=6. weekday_name(DEPRECATED) The name of day in a week (ex: Friday) weekofyearThe week ordinal of the year. yearThe year of the datetime. timetuple Methods
argsort([ascending, kind])Return the indices that would sort this array. astype(dtype[, copy])Cast to a NumPy array with ‘dtype’. ceil(freq[, ambiguous, nonexistent])Perform ceil operation on the data to the specified freq.copy([deep])Return a copy of the array. day_name([locale])Return the day names of the DateTimeIndex with specified locale. dropna()Return ExtensionArray without NA values factorize([na_sentinel])Encode the extension array as an enumerated type. fillna([value, method, limit])Fill NA/NaN values using the specified method. floor(freq[, ambiguous, nonexistent])Perform floor operation on the data to the specified freq.isna()A 1-D array indicating if each value is missing. max([axis, skipna])Return the maximum value of the Array or maximum along an axis. min([axis, skipna])Return the minimum value of the Array or minimum along an axis. month_name([locale])Return the month names of the DateTimeIndex with specified locale. normalize()Convert times to midnight. repeat(repeats, *args, **kwargs)Repeat elements of an array. round(freq[, ambiguous, nonexistent])Perform round operation on the data to the specified freq.searchsorted(value[, side, sorter])Find indices where elements should be inserted to maintain order. shift([periods, fill_value])Shift values by desired number. strftime(date_format)Convert to Index using specified date_format. take(indices[, allow_fill, fill_value])Take elements from an array. to_julian_date()Convert Datetime Array to float64 ndarray of Julian Dates. to_period([freq])Cast to PeriodArray/Index at a particular frequency. to_perioddelta(freq)Calculate TimedeltaArray of difference between index values and index converted to PeriodArray at specified freq. to_pydatetime()Return Datetime Array/Index as object ndarray of datetime.datetime objects tz_convert(tz)Convert tz-aware Datetime Array/Index from one time zone to another. tz_localize(tz[, ambiguous, nonexistent, errors])Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index. unique()Compute the ExtensionArray of unique values. value_counts([dropna])Return a Series containing counts of unique values. view([dtype])New view on this array with the same data. map -
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.arrays.DatetimeArray.html