Pandas.DatetimeIndex — Pandas 1.4.3 Documentation
Maybe your like
Site Navigation
- Getting started
- User Guide
- API reference
- Development
- Release notes
- GitHub
- Mastodon
Site Navigation
- Getting started
- User Guide
- API reference
- Development
- Release notes
- GitHub
- Mastodon
- Input/output
- General functions
- Series
- DataFrame
- pandas arrays, scalars, and data types
- Index objects
- pandas.Index
- pandas.Index.values
- pandas.Index.is_monotonic_increasing
- pandas.Index.is_monotonic_decreasing
- pandas.Index.is_unique
- pandas.Index.has_duplicates
- pandas.Index.hasnans
- pandas.Index.dtype
- pandas.Index.inferred_type
- pandas.Index.shape
- pandas.Index.name
- pandas.Index.names
- pandas.Index.nbytes
- pandas.Index.ndim
- pandas.Index.size
- pandas.Index.empty
- pandas.Index.T
- pandas.Index.memory_usage
- pandas.Index.all
- pandas.Index.any
- pandas.Index.argmin
- pandas.Index.argmax
- pandas.Index.copy
- pandas.Index.delete
- pandas.Index.drop
- pandas.Index.drop_duplicates
- pandas.Index.duplicated
- pandas.Index.equals
- pandas.Index.factorize
- pandas.Index.identical
- pandas.Index.insert
- pandas.Index.is_
- pandas.Index.is_boolean
- pandas.Index.is_categorical
- pandas.Index.is_floating
- pandas.Index.is_integer
- pandas.Index.is_interval
- pandas.Index.is_numeric
- pandas.Index.is_object
- pandas.Index.min
- pandas.Index.max
- pandas.Index.reindex
- pandas.Index.rename
- pandas.Index.repeat
- pandas.Index.where
- pandas.Index.take
- pandas.Index.putmask
- pandas.Index.unique
- pandas.Index.nunique
- pandas.Index.value_counts
- pandas.Index.set_names
- pandas.Index.droplevel
- pandas.Index.fillna
- pandas.Index.dropna
- pandas.Index.isna
- pandas.Index.notna
- pandas.Index.astype
- pandas.Index.item
- pandas.Index.map
- pandas.Index.ravel
- pandas.Index.to_list
- pandas.Index.to_series
- pandas.Index.to_frame
- pandas.Index.view
- pandas.Index.argsort
- pandas.Index.searchsorted
- pandas.Index.sort_values
- pandas.Index.shift
- pandas.Index.append
- pandas.Index.join
- pandas.Index.intersection
- pandas.Index.union
- pandas.Index.difference
- pandas.Index.symmetric_difference
- pandas.Index.asof
- pandas.Index.asof_locs
- pandas.Index.get_indexer
- pandas.Index.get_indexer_for
- pandas.Index.get_indexer_non_unique
- pandas.Index.get_level_values
- pandas.Index.get_loc
- pandas.Index.get_slice_bound
- pandas.Index.isin
- pandas.Index.slice_indexer
- pandas.Index.slice_locs
- pandas.RangeIndex
- pandas.RangeIndex.start
- pandas.RangeIndex.stop
- pandas.RangeIndex.step
- pandas.RangeIndex.from_range
- pandas.CategoricalIndex
- pandas.CategoricalIndex.codes
- pandas.CategoricalIndex.categories
- pandas.CategoricalIndex.ordered
- pandas.CategoricalIndex.rename_categories
- pandas.CategoricalIndex.reorder_categories
- pandas.CategoricalIndex.add_categories
- pandas.CategoricalIndex.remove_categories
- pandas.CategoricalIndex.remove_unused_categories
- pandas.CategoricalIndex.set_categories
- pandas.CategoricalIndex.as_ordered
- pandas.CategoricalIndex.as_unordered
- pandas.CategoricalIndex.map
- pandas.CategoricalIndex.equals
- pandas.IntervalIndex
- pandas.IntervalIndex.from_arrays
- pandas.IntervalIndex.from_tuples
- pandas.IntervalIndex.from_breaks
- pandas.IntervalIndex.left
- pandas.IntervalIndex.right
- pandas.IntervalIndex.mid
- pandas.IntervalIndex.closed
- pandas.IntervalIndex.length
- pandas.IntervalIndex.values
- pandas.IntervalIndex.is_empty
- pandas.IntervalIndex.is_non_overlapping_monotonic
- pandas.IntervalIndex.is_overlapping
- pandas.IntervalIndex.get_loc
- pandas.IntervalIndex.get_indexer
- pandas.IntervalIndex.set_closed
- pandas.IntervalIndex.contains
- pandas.IntervalIndex.overlaps
- pandas.IntervalIndex.to_tuples
- pandas.MultiIndex
- pandas.MultiIndex.from_arrays
- pandas.MultiIndex.from_tuples
- pandas.MultiIndex.from_product
- pandas.MultiIndex.from_frame
- pandas.MultiIndex.names
- pandas.MultiIndex.levels
- pandas.MultiIndex.codes
- pandas.MultiIndex.nlevels
- pandas.MultiIndex.levshape
- pandas.MultiIndex.dtypes
- pandas.MultiIndex.set_levels
- pandas.MultiIndex.set_codes
- pandas.MultiIndex.to_flat_index
- pandas.MultiIndex.to_frame
- pandas.MultiIndex.sortlevel
- pandas.MultiIndex.droplevel
- pandas.MultiIndex.swaplevel
- pandas.MultiIndex.reorder_levels
- pandas.MultiIndex.remove_unused_levels
- pandas.MultiIndex.drop
- pandas.MultiIndex.copy
- pandas.MultiIndex.append
- pandas.MultiIndex.truncate
- pandas.MultiIndex.get_loc
- pandas.MultiIndex.get_locs
- pandas.MultiIndex.get_loc_level
- pandas.MultiIndex.get_indexer
- pandas.MultiIndex.get_level_values
- pandas.IndexSlice
- pandas.DatetimeIndex
- pandas.DatetimeIndex.year
- pandas.DatetimeIndex.month
- pandas.DatetimeIndex.day
- pandas.DatetimeIndex.hour
- pandas.DatetimeIndex.minute
- pandas.DatetimeIndex.second
- pandas.DatetimeIndex.microsecond
- pandas.DatetimeIndex.nanosecond
- pandas.DatetimeIndex.date
- pandas.DatetimeIndex.time
- pandas.DatetimeIndex.timetz
- pandas.DatetimeIndex.dayofyear
- pandas.DatetimeIndex.day_of_year
- pandas.DatetimeIndex.dayofweek
- pandas.DatetimeIndex.day_of_week
- pandas.DatetimeIndex.weekday
- pandas.DatetimeIndex.quarter
- pandas.DatetimeIndex.tz
- pandas.DatetimeIndex.freqstr
- pandas.DatetimeIndex.is_month_start
- pandas.DatetimeIndex.is_month_end
- pandas.DatetimeIndex.is_quarter_start
- pandas.DatetimeIndex.is_quarter_end
- pandas.DatetimeIndex.is_year_start
- pandas.DatetimeIndex.is_year_end
- pandas.DatetimeIndex.is_leap_year
- pandas.DatetimeIndex.inferred_freq
- pandas.DatetimeIndex.normalize
- pandas.DatetimeIndex.strftime
- pandas.DatetimeIndex.snap
- pandas.DatetimeIndex.tz_convert
- pandas.DatetimeIndex.tz_localize
- pandas.DatetimeIndex.round
- pandas.DatetimeIndex.floor
- pandas.DatetimeIndex.ceil
- pandas.DatetimeIndex.to_period
- pandas.DatetimeIndex.to_pydatetime
- pandas.DatetimeIndex.to_series
- pandas.DatetimeIndex.to_frame
- pandas.DatetimeIndex.month_name
- pandas.DatetimeIndex.day_name
- pandas.DatetimeIndex.mean
- pandas.DatetimeIndex.std
- pandas.DatetimeIndex.year
- pandas.DatetimeIndex.month
- pandas.DatetimeIndex.day
- pandas.DatetimeIndex.hour
- pandas.DatetimeIndex.minute
- pandas.DatetimeIndex.second
- pandas.DatetimeIndex.microsecond
- pandas.DatetimeIndex.nanosecond
- pandas.DatetimeIndex.date
- pandas.DatetimeIndex.time
- pandas.DatetimeIndex.timetz
- pandas.DatetimeIndex.dayofyear
- pandas.DatetimeIndex.day_of_year
- pandas.DatetimeIndex.dayofweek
- pandas.DatetimeIndex.day_of_week
- pandas.DatetimeIndex.weekday
- pandas.DatetimeIndex.quarter
- pandas.DatetimeIndex.tz
- pandas.DatetimeIndex.freq
- pandas.DatetimeIndex.freqstr
- pandas.DatetimeIndex.is_month_start
- pandas.DatetimeIndex.is_month_end
- pandas.DatetimeIndex.is_quarter_start
- pandas.DatetimeIndex.is_quarter_end
- pandas.DatetimeIndex.is_year_start
- pandas.DatetimeIndex.is_year_end
- pandas.DatetimeIndex.is_leap_year
- pandas.DatetimeIndex.inferred_freq
- pandas.DatetimeIndex.indexer_at_time
- pandas.DatetimeIndex.indexer_between_time
- pandas.DatetimeIndex.normalize
- pandas.DatetimeIndex.strftime
- pandas.DatetimeIndex.snap
- pandas.DatetimeIndex.tz_convert
- pandas.DatetimeIndex.tz_localize
- pandas.DatetimeIndex.round
- pandas.DatetimeIndex.floor
- pandas.DatetimeIndex.ceil
- pandas.DatetimeIndex.month_name
- pandas.DatetimeIndex.day_name
- pandas.DatetimeIndex.as_unit
- pandas.DatetimeIndex.to_period
- pandas.DatetimeIndex.to_pydatetime
- pandas.DatetimeIndex.to_series
- pandas.DatetimeIndex.to_frame
- pandas.DatetimeIndex.mean
- pandas.DatetimeIndex.std
- pandas.TimedeltaIndex
- pandas.TimedeltaIndex.days
- pandas.TimedeltaIndex.seconds
- pandas.TimedeltaIndex.microseconds
- pandas.TimedeltaIndex.nanoseconds
- pandas.TimedeltaIndex.components
- pandas.TimedeltaIndex.inferred_freq
- pandas.TimedeltaIndex.as_unit
- pandas.TimedeltaIndex.to_pytimedelta
- pandas.TimedeltaIndex.to_series
- pandas.TimedeltaIndex.round
- pandas.TimedeltaIndex.floor
- pandas.TimedeltaIndex.ceil
- pandas.TimedeltaIndex.to_frame
- pandas.TimedeltaIndex.mean
- pandas.PeriodIndex
- pandas.PeriodIndex.day
- pandas.PeriodIndex.dayofweek
- pandas.PeriodIndex.day_of_week
- pandas.PeriodIndex.dayofyear
- pandas.PeriodIndex.day_of_year
- pandas.PeriodIndex.days_in_month
- pandas.PeriodIndex.daysinmonth
- pandas.PeriodIndex.end_time
- pandas.PeriodIndex.freq
- pandas.PeriodIndex.freqstr
- pandas.PeriodIndex.hour
- pandas.PeriodIndex.is_leap_year
- pandas.PeriodIndex.minute
- pandas.PeriodIndex.month
- pandas.PeriodIndex.quarter
- pandas.PeriodIndex.qyear
- pandas.PeriodIndex.second
- pandas.PeriodIndex.start_time
- pandas.PeriodIndex.week
- pandas.PeriodIndex.weekday
- pandas.PeriodIndex.weekofyear
- pandas.PeriodIndex.year
- pandas.PeriodIndex.asfreq
- pandas.PeriodIndex.strftime
- pandas.PeriodIndex.to_timestamp
- pandas.PeriodIndex.from_fields
- pandas.PeriodIndex.from_ordinals
- Date offsets
- Window
- GroupBy
- Resampling
- Style
- Plotting
- Options and settings
- Extensions
- Testing
- Missing values
- API reference
- Index objects
- pandas.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.
Changed in version 2.0.0: The various numeric date/time attributes (day, month, year etc.) now have dtype int32. Previously they had dtype int64.
Parameters: dataarray-like (1-dimensional)Datetime-like data to construct index with.
freqstr or pandas offset object, optionalOne 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.
tzpytz.timezone or dateutil.tz.tzfile or datetime.tzinfo or strSet the Timezone of the data.
normalizebool, default FalseNormalize start/end dates to midnight before generating date range.
Deprecated since version 2.1.0.
closed{‘left’, ‘right’}, optionalSet whether to include start and end that are on the boundary. The default includes boundary points on either end.
Deprecated since version 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.
If True, parse dates in data with the day first order.
yearfirstbool, default FalseIf True parse dates in data with the year first order.
dtypenumpy.dtype or DatetimeTZDtype or str, default NoneNote that the only NumPy dtype allowed is datetime64[ns].
copybool, default FalseMake a copy of input ndarray.
namelabel, default NoneName to be stored in the index.
Attributes
year | The year of the datetime. |
month | The month as January=1, December=12. |
day | The day of the datetime. |
hour | The hours of the datetime. |
minute | The minutes of the datetime. |
second | The seconds of the datetime. |
microsecond | The microseconds of the datetime. |
nanosecond | The nanoseconds of the datetime. |
date | Returns numpy array of python datetime.date objects. |
time | Returns numpy array of datetime.time objects. |
timetz | Returns numpy array of datetime.time objects with timezones. |
dayofyear | The ordinal day of the year. |
day_of_year | The ordinal day of the year. |
dayofweek | The day of the week with Monday=0, Sunday=6. |
day_of_week | The day of the week with Monday=0, Sunday=6. |
weekday | The day of the week with Monday=0, Sunday=6. |
quarter | The quarter of the date. |
tz | Return the timezone. |
freqstr | Return the frequency object as a string if it's set, otherwise None. |
is_month_start | Indicates whether the date is the first day of the month. |
is_month_end | Indicates whether the date is the last day of the month. |
is_quarter_start | Indicator for whether the date is the first day of a quarter. |
is_quarter_end | Indicator for whether the date is the last day of a quarter. |
is_year_start | Indicate whether the date is the first day of a year. |
is_year_end | Indicate whether the date is the last day of the year. |
is_leap_year | Boolean indicator if the date belongs to a leap year. |
inferred_freq | Tries to return a string representing a frequency generated by infer_freq. |
freq |
Methods
normalize(*args, **kwargs) | Convert times to midnight. |
strftime(date_format) | Convert to Index using specified date_format. |
snap([freq]) | Snap time stamps to nearest occurring frequency. |
tz_convert(tz) | Convert tz-aware Datetime Array/Index from one time zone to another. |
tz_localize(tz[, ambiguous, nonexistent]) | Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index. |
round(*args, **kwargs) | Perform round operation on the data to the specified freq. |
floor(*args, **kwargs) | Perform floor operation on the data to the specified freq. |
ceil(*args, **kwargs) | Perform ceil operation on the data to the specified freq. |
to_period(*args, **kwargs) | Cast to PeriodArray/PeriodIndex at a particular frequency. |
to_pydatetime(*args, **kwargs) | Return an ndarray of datetime.datetime objects. |
to_series([index, name]) | Create a Series with both index and values equal to the index keys. |
to_frame([index, name]) | Create a DataFrame with a column containing the Index. |
month_name(*args, **kwargs) | Return the month names with specified locale. |
day_name(*args, **kwargs) | Return the day names with specified locale. |
mean(*[, skipna, axis]) | Return the mean value of the Array. |
std(*args, **kwargs) | Return sample standard deviation over requested axis. |
See also
IndexThe base pandas Index type.
TimedeltaIndexIndex of timedelta64 data.
PeriodIndexIndex of Period data.
to_datetimeConvert argument to datetime.
date_rangeCreate a fixed-frequency DatetimeIndex.
Notes
To learn more about the frequency strings, please see this link.
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) On this page- DatetimeIndex
Tag » Add Datetimeindex To Pandas Dataframe
-
How Do I Properly Set The Datetimeindex For A Pandas Datetime ...
-
Pandas._frame — Pandas 1.4.3 Documentation
-
Pandas Time Series Examples: DatetimeIndex, PeriodIndex And ...
-
Python Pandas - Create A Datetime With DateTimeIndex
-
Python | Pandas _frame() - GeeksforGeeks
-
Adding Missing Dates In Datetime Index In Pandas DataFrame
-
Extract Month And Year To A New Column In Pandas - Data Interview Qs
-
Convert Pandas DatetimeIndex To String - Spark By {Examples}
-
Indexing Time Series Data In Pandas
-
Pandas Create Datetimeindex Between Dates Code Example
-
Set DatetimeIndex For Pandas DataFrame In Python (3 Examples)
-
Working With Pandas Datetime - Kanoki
-
ndas.DatetimeIndex - Apache Spark
-
Working With Datetime Index In Pandas | By Sergi Lehkyi