pandas.DatetimeIndex¶
- class pandas.DatetimeIndex¶
Immutable ndarray of datetime64 data, represented internally as int64, and which can be boxed to Timestamp objects that are subclasses of datetime and carry metadata such as frequency information.
Parameters : data : array-like (1-dimensional), optional
Optional datetime-like data to construct index with
copy : bool
Make a copy of input ndarray
freq : string or pandas offset object, optional
One of pandas date offset strings or corresponding objects
start : starting value, datetime-like, optional
If data is None, start is used as the start point in generating regular timestamp data.
periods : int, optional, > 0
Number of periods to generate, if generating index. Takes precedence over end argument
end : end time, datetime-like, optional
If periods is none, generated index will extend to first conforming time on or just past end argument
closed : string or None, default None
Make the interval closed with respect to the given frequency to the ‘left’, ‘right’, or both sides (None)
tz : pytz.timezone or dateutil.tz.tzfile
ambiguous : ‘infer’, bool-ndarray, ‘NaT’, default ‘raise’
- ‘infer’ will attempt to infer fall dst-transition hours based on order
- bool-ndarray where True signifies a DST time, False signifies 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
infer_dst : boolean, default False (DEPRECATED)
Attempt to infer fall dst-transition hours based on order
name : object
Name to be stored in the index
Attributes
T return the transpose, which is by definition self asi8 asobject base return the base object if the memory of the underlying data is shared data return the data pointer of the underlying data date Returns numpy array of datetime.date. day The days of the datetime dayofweek The day of the week with Monday=0, Sunday=6 dayofyear The ordinal day of the year dtype flags freq get/set the frequncy of the Index freqstr return the frequency object as a string if its set, otherwise None hour The hours of the datetime inferred_type is_all_dates is_monotonic alias for is_monotonic_increasing (deprecated) is_monotonic_decreasing return if the index is monotonic decreasing (only equal or is_monotonic_increasing return if the index is monotonic increasing (only equal or is_month_end Logical indicating if last day of month (defined by frequency) is_month_start Logical indicating if first day of month (defined by frequency) is_quarter_end Logical indicating if last day of quarter (defined by frequency) is_quarter_start Logical indicating if first day of quarter (defined by frequency) is_year_end Logical indicating if last day of year (defined by frequency) is_year_start Logical indicating if first day of year (defined by frequency) itemsize return the size of the dtype of the item of the underlying data microsecond The microseconds of the datetime millisecond The milliseconds of the datetime minute The minutes of the datetime month The month as January=1, December=12 names nanosecond The nanoseconds of the datetime nbytes return the number of bytes in the underlying data ndim return the number of dimensions of the underlying data, by definition 1 nlevels quarter The quarter of the date second The seconds of the datetime shape return a tuple of the shape of the underlying data size return the number of elements in the underlying data strides return the strides of the underlying data time Returns numpy array of datetime.time. tzinfo Alias for tz attribute values return the underlying data as an ndarray week The week ordinal of the year weekday The day of the week with Monday=0, Sunday=6 weekofyear The week ordinal of the year year The year of the datetime hasnans inferred_freq is_normalized is_unique name offset resolution tz Methods
all([axis, out]) Returns True if all elements evaluate to True. any([axis, out]) Returns True if any of the elements of a evaluate to True. append(other) Append a collection of Index options together argmax([axis]) return a ndarray of the maximum argument indexer argmin([axis]) return a ndarray of the minimum argument indexer argsort(*args, **kwargs) return an ndarray indexer of the underlying data asof(label) For a sorted index, return the most recent label up to and including the passed label. asof_locs(where, mask) where : array of timestamps astype(dtype) copy([names, name, dtype, deep]) Make a copy of this object. delete(loc) Make a new DatetimeIndex with passed location(s) deleted. diff(*args, **kwargs) difference(other) Compute sorted set difference of two Index objects drop(labels) Make new Index with passed list of labels deleted drop_duplicates([take_last]) Return Index with duplicate values removed duplicated([take_last]) Return boolean Index denoting duplicate values equals(other) Determines if two Index objects contain the same elements. factorize([sort, na_sentinel]) Encode the object as an enumerated type or categorical variable format([name, formatter]) Render a string representation of the Index get_duplicates() get_indexer(target[, method, limit]) Compute indexer and mask for new index given the current index. get_indexer_for(target, **kwargs) guaranteed return of an indexer even when non-unique get_indexer_non_unique(target, **kwargs) return an indexer suitable for taking from a non unique index get_level_values(level) Return vector of label values for requested level, equal to the length get_loc(key) Get integer location for requested label get_value(series, key) Fast lookup of value from 1-dimensional ndarray. get_value_maybe_box(series, key) get_values() return the underlying data as an ndarray groupby(f) holds_integer() identical(other) Similar to equals, but check that other comparable attributes are indexer_at_time(time[, asof]) Select values at particular time of day (e.g. indexer_between_time(start_time, end_time[, ...]) Select values between particular times of day (e.g., 9:00-9:30AM) insert(loc, item) Make new Index inserting new item at location intersection(other) Specialized intersection for DatetimeIndex objects. May be much faster is_(other) More flexible, faster check like is but that works through views is_boolean() is_floating() is_integer() is_lexsorted_for_tuple(tup) is_mixed() is_numeric() is_object() is_type_compatible(typ) isin(values) Compute boolean array of whether each index value is found in the item() return the first element of the underlying data as a python scalar join(other[, how, level, return_indexers]) See Index.join map(f) max([axis]) return the maximum value of the Index min([axis]) return the minimum value of the Index normalize() Return DatetimeIndex with times to midnight. Length is unaltered nunique([dropna]) Return number of unique elements in the object. order([return_indexer, ascending]) Return sorted copy of Index putmask(mask, value) return a new Index of the values set with the mask ravel([order]) return an ndarray of the flattened values of the underlying data reindex(target[, method, level, limit]) Create index with target’s values (move/add/delete values as necessary) rename(name[, inplace]) Set new names on index. repeat(repeats[, axis]) Analogous to ndarray.repeat searchsorted(key[, side]) set_names(names[, level, inplace]) Set new names on index. set_value(arr, key, value) Fast lookup of value from 1-dimensional ndarray. shift(n[, freq]) Specialized shift which produces a DatetimeIndex slice_indexer([start, end, step]) Index.slice_indexer, customized to handle time slicing slice_locs([start, end]) Index.slice_locs, customized to handle partial ISO-8601 string slicing snap([freq]) Snap time stamps to nearest occurring frequency sort(*args, **kwargs) summary([name]) sym_diff(other[, result_name]) Compute the sorted symmetric difference of two Index objects. take(indices[, axis]) Analogous to ndarray.take to_datetime([dayfirst]) to_julian_date() Convert DatetimeIndex to Float64Index of Julian Dates. to_native_types([slicer]) slice and dice then format to_period([freq]) Cast to PeriodIndex at a particular frequency to_pydatetime() Return DatetimeIndex as object ndarray of datetime.datetime objects to_series([keep_tz]) Create a Series with both index and values equal to the index keys tolist() return a list of the underlying data transpose() return the transpose, which is by definition self tz_convert(tz) Convert tz-aware DatetimeIndex from one time zone to another (using pytz/dateutil) tz_localize(*args, **kwargs) Localize tz-naive DatetimeIndex to given time zone (using pytz/dateutil), union(other) Specialized union for DatetimeIndex objects. If combine union_many(others) A bit of a hack to accelerate unioning a collection of indexes unique() Index.unique with handling for DatetimeIndex/PeriodIndex metadata value_counts([normalize, sort, ascending, ...]) Returns object containing counts of unique values. view([cls])