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.

Parameters:
values : Series, Index, DatetimeArray, ndarray

The datetime data.

For DatetimeArray values (or a Series or Index boxing one), dtype and freq will be extracted from values, 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

asi8 Integer representation of the values.
date Returns numpy array of python datetime.date objects (namely, the date part of Timestamps without timezone information).
day The days of the datetime.
dayofweek The day of the week with Monday=0, Sunday=6.
dayofyear The ordinal day of the year.
days_in_month The number of days in the month.
daysinmonth The number of days in the month.
dtype The dtype for the DatetimeArray.
freq Return the frequency object if it is set, otherwise None.
freqstr Return the frequency object as a string if its set, otherwise None
hour The hours of the datetime.
inferred_freq Tryies to return a string representing a frequency guess, generated by infer_freq.
is_leap_year Boolean indicator if the date belongs to a leap year.
is_month_end Indicates whether the date is the last day of the month.
is_month_start Indicates whether the date is the first day of the month.
is_normalized Returns True if all of the dates are at midnight (“no time”)
is_quarter_end Indicator for whether the date is the last day of a quarter.
is_quarter_start Indicator for whether the date is the first day of a quarter.
is_year_end Indicate whether the date is the last day of the year.
is_year_start Indicate whether the date is the first day of a year.
microsecond The microseconds of the datetime.
minute The minutes of the datetime.
month The month as January=1, December=12.
nanosecond The nanoseconds of the datetime.
nbytes The number of bytes needed to store this object in memory.
quarter The quarter of the date.
resolution Returns day, hour, minute, second, millisecond or microsecond
second The seconds of the datetime.
shape Return a tuple of the array dimensions.
size The number of elements in this array.
time Returns numpy array of datetime.time.
timetz Returns numpy array of datetime.time also containing timezone information.
tz Return timezone, if any.
tzinfo Alias for tz attribute
week The week ordinal of the year.
weekday The day of the week with Monday=0, Sunday=6.
weekday_name (DEPRECATED) The name of day in a week (ex: Friday)
weekofyear The week ordinal of the year.
year The 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  
Scroll To Top