Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Calcul scientifique
avec Python
Voir le programme détaillé
Module « pandas »

Classe « DatetimeIndex »

Informations générales

Héritage

                    builtins.object
                        ABC
                builtins.object
                    ABC
builtins.object
    DirNamesMixin
        PandasObject
builtins.object
    OpsMixin
        IndexOpsMixin
            Index
                ExtensionIndex
                    NDArrayBackedExtensionIndex
                        DatetimeIndexOpsMixin
                            DatetimeTimedeltaMixin
                                DatetimeIndex

Définition

class DatetimeIndex(DatetimeTimedeltaMixin):

help(DatetimeIndex)

Immutable ndarray-like of datetime64 data.

Represented internally as int64, and which can be boxed to Timestamp objects
that are subclasses of datetime and carry metadata.

.. versionchanged:: 2.0.0
    The various numeric date/time attributes (:attr:`~DatetimeIndex.day`,
    :attr:`~DatetimeIndex.month`, :attr:`~DatetimeIndex.year` etc.) now have dtype
    ``int32``. Previously they had dtype ``int64``.

Parameters
----------
data : array-like (1-dimensional)
    Datetime-like data to construct index with.
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.
tz : pytz.timezone or dateutil.tz.tzfile or datetime.tzinfo or str
    Set the Timezone of the data.
normalize : bool, default False
    Normalize start/end dates to midnight before generating date range.

    .. deprecated:: 2.1.0

closed : {'left', 'right'}, optional
    Set whether to include `start` and `end` that are on the
    boundary. The default includes boundary points on either end.

    .. deprecated:: 2.1.0

ambiguous : 'infer', bool-ndarray, '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.

    - '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.
dayfirst : bool, default False
    If True, parse dates in `data` with the day first order.
yearfirst : bool, default False
    If True parse dates in `data` with the year first order.
dtype : numpy.dtype or DatetimeTZDtype or str, default None
    Note that the only NumPy dtype allowed is `datetime64[ns]`.
copy : bool, default False
    Make a copy of input ndarray.
name : label, default None
    Name to be stored in the index.

Attributes
----------
year
month
day
hour
minute
second
microsecond
nanosecond
date
time
timetz
dayofyear
day_of_year
dayofweek
day_of_week
weekday
quarter
tz
freq
freqstr
is_month_start
is_month_end
is_quarter_start
is_quarter_end
is_year_start
is_year_end
is_leap_year
inferred_freq

Methods
-------
normalize
strftime
snap
tz_convert
tz_localize
round
floor
ceil
to_period
to_pydatetime
to_series
to_frame
month_name
day_name
mean
std

See Also
--------
Index : The base pandas Index type.
TimedeltaIndex : Index of timedelta64 data.
PeriodIndex : Index of Period data.
to_datetime : Convert argument to datetime.
date_range : Create a fixed-frequency DatetimeIndex.

Notes
-----
To learn more about the frequency strings, please see `this link
<https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`__.

Examples
--------
>>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
>>> idx
DatetimeIndex(['2020-01-01 10:00:00+00:00', '2020-02-01 11:00:00+00:00'],
dtype='datetime64[ns, UTC]', freq=None)

Constructeur(s)

Signature du constructeur Description
__new__(cls, data=None, freq: 'Frequency | lib.NoDefault' = <no_default>, tz=<no_default>, normalize: 'bool | lib.NoDefault' = <no_default>, closed=<no_default>, ambiguous: 'TimeAmbiguous' = 'raise', dayfirst: 'bool' = False, yearfirst: 'bool' = False, dtype: 'Dtype | None' = None, copy: 'bool' = False, name: 'Hashable | None' = None) -> 'Self'
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
array<pandas._libs.properties.CachedProperty object at 0x0000020D9B489680>
hasnans<pandas._libs.properties.CachedProperty object at 0x0000020D9B4B7140>
inferred_freq<pandas._libs.properties.CachedProperty object at 0x0000020D9B4B7AC0>
is_normalized<pandas._libs.properties.CachedProperty object at 0x0000020D9ADE8B40>
is_unique<pandas._libs.properties.CachedProperty object at 0x0000020D9B4886C0>
resolution<pandas._libs.properties.CachedProperty object at 0x0000020D9B4B7100>

Attributs statiques hérités de la classe DatetimeTimedeltaMixin

dtype, inferred_type

Liste des propriétés

Nom de la propriétéDescription
asi8
date
day
day_of_week
day_of_year
dayofweek
dayofyear
days_in_month
daysinmonth
dtype
empty
freq
freqstr
has_duplicates
hour
inferred_type
is_leap_year
is_monotonic_decreasing
is_monotonic_increasing
is_month_end
is_month_start
is_quarter_end
is_quarter_start
is_year_end
is_year_start
microsecond
minute
month
name
names
nanosecond
nbytes
ndim
nlevels
quarter
second
shape
size
T
time
timetz
tz
tzinfo
unit
values
weekday
year

Propriétés héritées de la classe IndexOpsMixin

array, is_unique

Liste des opérateurs

Opérateurs hérités de la classe DatetimeIndexOpsMixin

__contains__

Liste des opérateurs

Opérateurs hérités de la classe Index

__getitem__, __iadd__, __invert__, __neg__, __pos__, __setitem__

Liste des opérateurs

Opérateurs hérités de la classe OpsMixin

__add__, __and__, __eq__, __floordiv__, __ge__, __gt__, __le__, __lt__, __mod__, __mul__, __ne__, __or__, __pow__, __radd__, __rand__, __rfloordiv__, __rmod__, __rmul__, __ror__, __rpow__, __rsub__, __rtruediv__, __rxor__, __sub__, __truediv__, __xor__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__reduce__(self)
get_loc(self, key)
indexer_at_time(self, time, asof: 'bool' = False) -> 'npt.NDArray[np.intp]'
indexer_between_time(self, start_time, end_time, include_start: 'bool' = True, include_end: 'bool' = True) -> 'npt.NDArray[np.intp]'
isocalendar(self) -> 'DataFrame'
slice_indexer(self, start=None, end=None, step=None)
snap(self, freq: 'Frequency' = 'S') -> 'DatetimeIndex'
strftime(self, date_format) -> 'Index'
to_julian_date(self) -> 'Index'
tz_convert(self, tz) -> 'Self'
tz_localize(self, tz, ambiguous: 'TimeAmbiguous' = 'raise', nonexistent: 'TimeNonexistent' = 'raise') -> 'Self'

Méthodes héritées de la classe DatetimeTimedeltaMixin

__init_subclass__, __subclasshook__, as_unit, delete, insert, shift, take

Méthodes héritées de la classe DatetimeIndexOpsMixin

equals, format, mean

Méthodes héritées de la classe Index

__abs__, __array__, __array_ufunc__, __array_wrap__, __bool__, __copy__, __deepcopy__, __len__, __nonzero__, __repr__, all, any, append, argmax, argmin, argsort, asof, asof_locs, astype, copy, diff, difference, drop, drop_duplicates, droplevel, dropna, duplicated, fillna, get_indexer, get_indexer_for, get_indexer_non_unique, get_level_values, get_slice_bound, groupby, holds_integer, identical, infer_objects, intersection, is_, is_boolean, is_categorical, is_floating, is_integer, is_interval, is_numeric, is_object, isin, isna, isnull, join, map, max, memory_usage, min, notna, notnull, putmask, ravel, reindex, rename, repeat, round, set_names, slice_locs, sort, sort_values, sortlevel, symmetric_difference, to_flat_index, to_frame, to_series, union, unique, view, where

Méthodes héritées de la classe PandasObject

__sizeof__

Méthodes héritées de la classe DirNamesMixin

__dir__

Méthodes héritées de la classe IndexOpsMixin

__iter__, factorize, item, nunique, searchsorted, to_list, to_numpy, tolist, transpose, value_counts

Méthodes héritées de la classe OpsMixin

__divmod__, __rdivmod__

Méthodes héritées de la classe object

__delattr__, __format__, __getattribute__, __getstate__, __hash__, __reduce_ex__, __setattr__, __str__

Vous êtes un professionnel et vous avez besoin d'une formation ? Sensibilisation à
l'Intelligence Artificielle
Voir le programme détaillé