pandas.DataFrame.tz_localize   DataFrame.tz_localize(tz, axis=0, level=None, copy=True, ambiguous='raise', nonexistent='raise')[source]

Localize tz-naive index of a Series or DataFrame to target time zone. This operation localizes the Index. To localize the values in a timezone-naive Series, use Series.dt.tz_localize().  Parameters

tz:str or tzinfo

axis:the axis to localize

level:int, str, default None

If axis ia a MultiIndex, localize a specific level. Otherwise must be None.
copy:bool, default True

Also make a copy of the underlying data.
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 designates 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.
nonexistent:str, default ‘raise’

A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. Valid values are:  ‘shift_forward’ will shift the nonexistent time forward to the closest existing time ‘shift_backward’ will shift the nonexistent time backward to the closest existing time ‘NaT’ will return NaT where there are nonexistent times timedelta objects will shift nonexistent times by the timedelta ‘raise’ will raise an NonExistentTimeError if there are nonexistent times.     Returns
 Series or DataFrame

Same type as the input.    Raises
 TypeError

If the TimeSeries is tz-aware and tz is not None.     Examples Localize local times:
>>> s = pd.Series([1],
...               index=pd.DatetimeIndex(['2018-09-15 01:30:00']))
>>> s.tz_localize('CET')
2018-09-15 01:30:00+02:00    1
dtype: int64
  Be careful with DST changes. When there is sequential data, pandas can infer the DST time:
>>> s = pd.Series(range(7),
...               index=pd.DatetimeIndex(['2018-10-28 01:30:00',
...                                       '2018-10-28 02:00:00',
...                                       '2018-10-28 02:30:00',
...                                       '2018-10-28 02:00:00',
...                                       '2018-10-28 02:30:00',
...                                       '2018-10-28 03:00:00',
...                                       '2018-10-28 03:30:00']))
>>> s.tz_localize('CET', ambiguous='infer')
2018-10-28 01:30:00+02:00    0
2018-10-28 02:00:00+02:00    1
2018-10-28 02:30:00+02:00    2
2018-10-28 02:00:00+01:00    3
2018-10-28 02:30:00+01:00    4
2018-10-28 03:00:00+01:00    5
2018-10-28 03:30:00+01:00    6
dtype: int64
  In some cases, inferring the DST is impossible. In such cases, you can pass an ndarray to the ambiguous parameter to set the DST explicitly
>>> s = pd.Series(range(3),
...               index=pd.DatetimeIndex(['2018-10-28 01:20:00',
...                                       '2018-10-28 02:36:00',
...                                       '2018-10-28 03:46:00']))
>>> s.tz_localize('CET', ambiguous=np.array([True, True, False]))
2018-10-28 01:20:00+02:00    0
2018-10-28 02:36:00+02:00    1
2018-10-28 03:46:00+01:00    2
dtype: int64
  If the DST transition causes nonexistent times, you can shift these dates forward or backward with a timedelta object or ‘shift_forward’ or ‘shift_backward’.
>>> s = pd.Series(range(2),
...               index=pd.DatetimeIndex(['2015-03-29 02:30:00',
...                                       '2015-03-29 03:30:00']))
>>> s.tz_localize('Europe/Warsaw', nonexistent='shift_forward')
2015-03-29 03:00:00+02:00    0
2015-03-29 03:30:00+02:00    1
dtype: int64
>>> s.tz_localize('Europe/Warsaw', nonexistent='shift_backward')
2015-03-29 01:59:59.999999999+01:00    0
2015-03-29 03:30:00+02:00              1
dtype: int64
>>> s.tz_localize('Europe/Warsaw', nonexistent=pd.Timedelta('1H'))
2015-03-29 03:30:00+02:00    0
2015-03-29 03:30:00+02:00    1
dtype: int64


pandas.DataFrame.unstack   DataFrame.unstack(level=- 1, fill_value=None)[source]

Pivot a level of the (necessarily hierarchical) index labels. Returns a DataFrame having a new level of column labels whose inner-most level consists of the pivoted index labels. If the index is not a MultiIndex, the output will be a Series (the analogue of stack when the columns are not a MultiIndex).  Parameters

level:int, str, or list of these, default -1 (last level)

Level(s) of index to unstack, can pass level name.
fill_value:int, str or dict

Replace NaN with this value if the unstack produces missing values.    Returns
 Series or DataFrame
    See also  DataFrame.pivot

Pivot a table based on column values.  DataFrame.stack

Pivot a level of the column labels (inverse operation from unstack).    Examples
>>> index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'),
...                                    ('two', 'a'), ('two', 'b')])
>>> s = pd.Series(np.arange(1.0, 5.0), index=index)
>>> s
one  a   1.0
     b   2.0
two  a   3.0
     b   4.0
dtype: float64

>>> s.unstack(level=-1)
     a   b
one  1.0  2.0
two  3.0  4.0

>>> s.unstack(level=0)
   one  two
a  1.0   3.0
b  2.0   4.0

>>> df = s.unstack(level=0)
>>> df.unstack()
one  a  1.0
     b  2.0
two  a  3.0
     b  4.0
dtype: float64


pandas.DataFrame.update   DataFrame.update(other, join='left', overwrite=True, filter_func=None, errors='ignore')[source]

Modify in place using non-NA values from another DataFrame. Aligns on indices. There is no return value.  Parameters

other:DataFrame, or object coercible into a DataFrame

Should have at least one matching index/column label with the original DataFrame. If a Series is passed, its name attribute must be set, and that will be used as the column name to align with the original DataFrame.
join:{‘left’}, default ‘left’

Only left join is implemented, keeping the index and columns of the original object.
overwrite:bool, default True

How to handle non-NA values for overlapping keys:  True: overwrite original DataFrame’s values with values from other. False: only update values that are NA in the original DataFrame.
filter_func:callable(1d-array) -> bool 1d-array, optional

Can choose to replace values other than NA. Return True for values that should be updated.
errors:{‘raise’, ‘ignore’}, default ‘ignore’

If ‘raise’, will raise a ValueError if the DataFrame and other both contain non-NA data in the same place.    Returns

None:method directly changes calling object

  Raises
 ValueError

 When errors=’raise’ and there’s overlapping non-NA data. When errors is not either ‘ignore’ or ‘raise’   NotImplementedError

 If join != ‘left’       See also  dict.update

Similar method for dictionaries.  DataFrame.merge

For column(s)-on-column(s) operations.    Examples
>>> df = pd.DataFrame({'A': [1, 2, 3],
...                    'B': [400, 500, 600]})
>>> new_df = pd.DataFrame({'B': [4, 5, 6],
...                        'C': [7, 8, 9]})
>>> df.update(new_df)
>>> df
   A  B
0  1  4
1  2  5
2  3  6
  The DataFrame’s length does not increase as a result of the update, only values at matching index/column labels are updated.
>>> df = pd.DataFrame({'A': ['a', 'b', 'c'],
...                    'B': ['x', 'y', 'z']})
>>> new_df = pd.DataFrame({'B': ['d', 'e', 'f', 'g', 'h', 'i']})
>>> df.update(new_df)
>>> df
   A  B
0  a  d
1  b  e
2  c  f
  For Series, its name attribute must be set.
>>> df = pd.DataFrame({'A': ['a', 'b', 'c'],
...                    'B': ['x', 'y', 'z']})
>>> new_column = pd.Series(['d', 'e'], name='B', index=[0, 2])
>>> df.update(new_column)
>>> df
   A  B
0  a  d
1  b  y
2  c  e
>>> df = pd.DataFrame({'A': ['a', 'b', 'c'],
...                    'B': ['x', 'y', 'z']})
>>> new_df = pd.DataFrame({'B': ['d', 'e']}, index=[1, 2])
>>> df.update(new_df)
>>> df
   A  B
0  a  x
1  b  d
2  c  e
  If other contains NaNs the corresponding values are not updated in the original dataframe.
>>> df = pd.DataFrame({'A': [1, 2, 3],
...                    'B': [400, 500, 600]})
>>> new_df = pd.DataFrame({'B': [4, np.nan, 6]})
>>> df.update(new_df)
>>> df
   A      B
0  1    4.0
1  2  500.0
2  3    6.0


pandas.DataFrame.value_counts   DataFrame.value_counts(subset=None, normalize=False, sort=True, ascending=False, dropna=True)[source]

Return a Series containing counts of unique rows in the DataFrame.  New in version 1.1.0.   Parameters

subset:list-like, optional

Columns to use when counting unique combinations.
normalize:bool, default False

Return proportions rather than frequencies.
sort:bool, default True

Sort by frequencies.
ascending:bool, default False

Sort in ascending order.
dropna:bool, default True

Don’t include counts of rows that contain NA values.  New in version 1.3.0.     Returns
 Series
    See also  Series.value_counts

Equivalent method on Series.    Notes The returned Series will have a MultiIndex with one level per input column. By default, rows that contain any NA values are omitted from the result. By default, the resulting Series will be in descending order so that the first element is the most frequently-occurring row. Examples
>>> df = pd.DataFrame({'num_legs': [2, 4, 4, 6],
...                    'num_wings': [2, 0, 0, 0]},
...                   index=['falcon', 'dog', 'cat', 'ant'])
>>> df
        num_legs  num_wings
falcon         2          2
dog            4          0
cat            4          0
ant            6          0

>>> df.value_counts()
num_legs  num_wings
4         0            2
2         2            1
6         0            1
dtype: int64

>>> df.value_counts(sort=False)
num_legs  num_wings
2         2            1
4         0            2
6         0            1
dtype: int64

>>> df.value_counts(ascending=True)
num_legs  num_wings
2         2            1
6         0            1
4         0            2
dtype: int64

>>> df.value_counts(normalize=True)
num_legs  num_wings
4         0            0.50
2         2            0.25
6         0            0.25
dtype: float64
  With dropna set to False we can also count rows with NA values.
>>> df = pd.DataFrame({'first_name': ['John', 'Anne', 'John', 'Beth'],
...                    'middle_name': ['Smith', pd.NA, pd.NA, 'Louise']})
>>> df
  first_name middle_name
0       John       Smith
1       Anne        <NA>
2       John        <NA>
3       Beth      Louise

>>> df.value_counts()
first_name  middle_name
Beth        Louise         1
John        Smith          1
dtype: int64

>>> df.value_counts(dropna=False)
first_name  middle_name
Anne        NaN            1
Beth        Louise         1
John        Smith          1
            NaN            1
dtype: int64


pandas.DataFrame.values   propertyDataFrame.values

Return a Numpy representation of the DataFrame.  Warning We recommend using DataFrame.to_numpy() instead.  Only the values in the DataFrame will be returned, the axes labels will be removed.  Returns
 numpy.ndarray

The values of the DataFrame.      See also  DataFrame.to_numpy

Recommended alternative to this method.  DataFrame.index

Retrieve the index labels.  DataFrame.columns

Retrieving the column names.    Notes The dtype will be a lower-common-denominator dtype (implicit upcasting); that is to say if the dtypes (even of numeric types) are mixed, the one that accommodates all will be chosen. Use this with care if you are not dealing with the blocks. e.g. If the dtypes are float16 and float32, dtype will be upcast to float32. If dtypes are int32 and uint8, dtype will be upcast to int32. By numpy.find_common_type() convention, mixing int64 and uint64 will result in a float64 dtype. Examples A DataFrame where all columns are the same type (e.g., int64) results in an array of the same type.
>>> df = pd.DataFrame({'age':    [ 3,  29],
...                    'height': [94, 170],
...                    'weight': [31, 115]})
>>> df
   age  height  weight
0    3      94      31
1   29     170     115
>>> df.dtypes
age       int64
height    int64
weight    int64
dtype: object
>>> df.values
array([[  3,  94,  31],
       [ 29, 170, 115]])
  A DataFrame with mixed type columns(e.g., str/object, int64, float32) results in an ndarray of the broadest type that accommodates these mixed types (e.g., object).
>>> df2 = pd.DataFrame([('parrot',   24.0, 'second'),
...                     ('lion',     80.5, 1),
...                     ('monkey', np.nan, None)],
...                   columns=('name', 'max_speed', 'rank'))
>>> df2.dtypes
name          object
max_speed    float64
rank          object
dtype: object
>>> df2.values
array([['parrot', 24.0, 'second'],
       ['lion', 80.5, 1],
       ['monkey', nan, None]], dtype=object)


pandas.DataFrame.var   DataFrame.var(axis=None, skipna=True, level=None, ddof=1, numeric_only=None, **kwargs)[source]

Return unbiased variance over requested axis. Normalized by N-1 by default. This can be changed using the ddof argument.  Parameters

axis:{index (0), columns (1)}

skipna:bool, default True

Exclude NA/null values. If an entire row/column is NA, the result will be NA.
level:int or level name, default None

If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series.
ddof:int, default 1

Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
numeric_only:bool, default None

Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.    Returns
 Series or DataFrame (if level specified)
   Examples
>>> df = pd.DataFrame({'person_id': [0, 1, 2, 3],
...                   'age': [21, 25, 62, 43],
...                   'height': [1.61, 1.87, 1.49, 2.01]}
...                  ).set_index('person_id')
>>> df
           age  height
person_id
0           21    1.61
1           25    1.87
2           62    1.49
3           43    2.01

>>> df.var()
age       352.916667
height      0.056367
  Alternatively, ddof=0 can be set to normalize by N instead of N-1:
>>> df.var(ddof=0)
age       264.687500
height      0.042275


pandas.DataFrame.where   DataFrame.where(cond, other=NoDefault.no_default, inplace=False, axis=None, level=None, errors='raise', try_cast=NoDefault.no_default)[source]

Replace values where the condition is False.  Parameters

cond:bool Series/DataFrame, array-like, or callable

Where cond is True, keep the original value. Where False, replace with corresponding value from other. If cond is callable, it is computed on the Series/DataFrame and should return boolean Series/DataFrame or array. The callable must not change input Series/DataFrame (though pandas doesn’t check it).
other:scalar, Series/DataFrame, or callable

Entries where cond is False are replaced with corresponding value from other. If other is callable, it is computed on the Series/DataFrame and should return scalar or Series/DataFrame. The callable must not change input Series/DataFrame (though pandas doesn’t check it).
inplace:bool, default False

Whether to perform the operation in place on the data.
axis:int, default None

Alignment axis if needed.
level:int, default None

Alignment level if needed.
errors:str, {‘raise’, ‘ignore’}, default ‘raise’

Note that currently this parameter won’t affect the results and will always coerce to a suitable dtype.  ‘raise’ : allow exceptions to be raised. ‘ignore’ : suppress exceptions. On error return original object.
try_cast:bool, default None

Try to cast the result back to the input type (if possible).  Deprecated since version 1.3.0: Manually cast back if necessary.     Returns
 Same type as caller or None if inplace=True.
    See also  DataFrame.mask()

Return an object of same shape as self.    Notes The where method is an application of the if-then idiom. For each element in the calling DataFrame, if cond is True the element is used; otherwise the corresponding element from the DataFrame other is used. The signature for DataFrame.where() differs from numpy.where(). Roughly df1.where(m, df2) is equivalent to np.where(m, df1, df2). For further details and examples see the where documentation in indexing. Examples
>>> s = pd.Series(range(5))
>>> s.where(s > 0)
0    NaN
1    1.0
2    2.0
3    3.0
4    4.0
dtype: float64
>>> s.mask(s > 0)
0    0.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64

>>> s.where(s > 1, 10)
0    10
1    10
2    2
3    3
4    4
dtype: int64
>>> s.mask(s > 1, 10)
0     0
1     1
2    10
3    10
4    10
dtype: int64

>>> df = pd.DataFrame(np.arange(10).reshape(-1, 2), columns=['A', 'B'])
>>> df
   A  B
0  0  1
1  2  3
2  4  5
3  6  7
4  8  9
>>> m = df % 3 == 0
>>> df.where(m, -df)
   A  B
0  0 -1
1 -2  3
2 -4 -5
3  6 -7
4 -8  9
>>> df.where(m, -df) == np.where(m, df, -df)
      A     B
0  True  True
1  True  True
2  True  True
3  True  True
4  True  True
>>> df.where(m, -df) == df.mask(~m, -df)
      A     B
0  True  True
1  True  True
2  True  True
3  True  True
4  True  True


pandas.DataFrame.xs   DataFrame.xs(key, axis=0, level=None, drop_level=True)[source]

Return cross-section from the Series/DataFrame. This method takes a key argument to select data at a particular level of a MultiIndex.  Parameters

key:label or tuple of label

Label contained in the index, or partially in a MultiIndex.
axis:{0 or ‘index’, 1 or ‘columns’}, default 0

Axis to retrieve cross-section on.
level:object, defaults to first n levels (n=1 or len(key))

In case of a key partially contained in a MultiIndex, indicate which levels are used. Levels can be referred by label or position.
drop_level:bool, default True

If False, returns object with same levels as self.    Returns
 Series or DataFrame

Cross-section from the original Series or DataFrame corresponding to the selected index levels.      See also  DataFrame.loc

Access a group of rows and columns by label(s) or a boolean array.  DataFrame.iloc

Purely integer-location based indexing for selection by position.    Notes xs can not be used to set values. MultiIndex Slicers is a generic way to get/set values on any level or levels. It is a superset of xs functionality, see MultiIndex Slicers. Examples
>>> d = {'num_legs': [4, 4, 2, 2],
...      'num_wings': [0, 0, 2, 2],
...      'class': ['mammal', 'mammal', 'mammal', 'bird'],
...      'animal': ['cat', 'dog', 'bat', 'penguin'],
...      'locomotion': ['walks', 'walks', 'flies', 'walks']}
>>> df = pd.DataFrame(data=d)
>>> df = df.set_index(['class', 'animal', 'locomotion'])
>>> df
                           num_legs  num_wings
class  animal  locomotion
mammal cat     walks              4          0
       dog     walks              4          0
       bat     flies              2          2
bird   penguin walks              2          2
  Get values at specified index
>>> df.xs('mammal')
                   num_legs  num_wings
animal locomotion
cat    walks              4          0
dog    walks              4          0
bat    flies              2          2
  Get values at several indexes
>>> df.xs(('mammal', 'dog'))
            num_legs  num_wings
locomotion
walks              4          0
  Get values at specified index and level
>>> df.xs('cat', level=1)
                   num_legs  num_wings
class  locomotion
mammal walks              4          0
  Get values at several indexes and levels
>>> df.xs(('bird', 'walks'),
...       level=[0, 'locomotion'])
         num_legs  num_wings
animal
penguin         2          2
  Get values at specified column and axis
>>> df.xs('num_wings', axis=1)
class   animal   locomotion
mammal  cat      walks         0
        dog      walks         0
        bat      flies         2
bird    penguin  walks         2
Name: num_wings, dtype: int64


pandas.date_range   pandas.date_range(start=None, end=None, periods=None, freq=None, tz=None, normalize=False, name=None, closed=NoDefault.no_default, inclusive=None, **kwargs)[source]

Return a fixed frequency DatetimeIndex. Returns the range of equally spaced time points (where the difference between any two adjacent points is specified by the given frequency) such that they all satisfy start <[=] x <[=] end, where the first one and the last one are, resp., the first and last time points in that range that fall on the boundary of freq (if given as a frequency string) or that are valid for freq (if given as a pandas.tseries.offsets.DateOffset). (If exactly one of start, end, or freq is not specified, this missing parameter can be computed given periods, the number of timesteps in the range. See the note below.)  Parameters

start:str or datetime-like, optional

Left bound for generating dates.
end:str or datetime-like, optional

Right bound for generating dates.
periods:int, optional

Number of periods to generate.
freq:str or DateOffset, default ‘D’

Frequency strings can have multiples, e.g. ‘5H’. See here for a list of frequency aliases.
tz:str or tzinfo, optional

Time zone name for returning localized DatetimeIndex, for example ‘Asia/Hong_Kong’. By default, the resulting DatetimeIndex is timezone-naive.
normalize:bool, default False

Normalize start/end dates to midnight before generating date range.
name:str, default None

Name of the resulting DatetimeIndex.
closed:{None, ‘left’, ‘right’}, optional

Make the interval closed with respect to the given frequency to the ‘left’, ‘right’, or both sides (None, the default).  Deprecated since version 1.4.0: Argument closed has been deprecated to standardize boundary inputs. Use inclusive instead, to set each bound as closed or open.
inclusive:{“both”, “neither”, “left”, “right”}, default “both”

Include boundaries; Whether to set each bound as closed or open.  New in version 1.4.0.   **kwargs

For compatibility. Has no effect on the result.    Returns

rng:DatetimeIndex

    See also  DatetimeIndex

An immutable container for datetimes.  timedelta_range

Return a fixed frequency TimedeltaIndex.  period_range

Return a fixed frequency PeriodIndex.  interval_range

Return a fixed frequency IntervalIndex.    Notes Of the four parameters start, end, periods, and freq, exactly three must be specified. If freq is omitted, the resulting DatetimeIndex will have periods linearly spaced elements between start and end (closed on both sides). To learn more about the frequency strings, please see this link. Examples Specifying the values The next four examples generate the same DatetimeIndex, but vary the combination of start, end and periods. Specify start and end, with the default daily frequency.
>>> pd.date_range(start='1/1/2018', end='1/08/2018')
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
               '2018-01-05', '2018-01-06', '2018-01-07', '2018-01-08'],
              dtype='datetime64[ns]', freq='D')
  Specify start and periods, the number of periods (days).
>>> pd.date_range(start='1/1/2018', periods=8)
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
               '2018-01-05', '2018-01-06', '2018-01-07', '2018-01-08'],
              dtype='datetime64[ns]', freq='D')
  Specify end and periods, the number of periods (days).
>>> pd.date_range(end='1/1/2018', periods=8)
DatetimeIndex(['2017-12-25', '2017-12-26', '2017-12-27', '2017-12-28',
               '2017-12-29', '2017-12-30', '2017-12-31', '2018-01-01'],
              dtype='datetime64[ns]', freq='D')
  Specify start, end, and periods; the frequency is generated automatically (linearly spaced).
>>> pd.date_range(start='2018-04-24', end='2018-04-27', periods=3)
DatetimeIndex(['2018-04-24 00:00:00', '2018-04-25 12:00:00',
               '2018-04-27 00:00:00'],
              dtype='datetime64[ns]', freq=None)
  Other Parameters Changed the freq (frequency) to 'M' (month end frequency).
>>> pd.date_range(start='1/1/2018', periods=5, freq='M')
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31', '2018-04-30',
               '2018-05-31'],
              dtype='datetime64[ns]', freq='M')
  Multiples are allowed
>>> pd.date_range(start='1/1/2018', periods=5, freq='3M')
DatetimeIndex(['2018-01-31', '2018-04-30', '2018-07-31', '2018-10-31',
               '2019-01-31'],
              dtype='datetime64[ns]', freq='3M')
  freq can also be specified as an Offset object.
>>> pd.date_range(start='1/1/2018', periods=5, freq=pd.offsets.MonthEnd(3))
DatetimeIndex(['2018-01-31', '2018-04-30', '2018-07-31', '2018-10-31',
               '2019-01-31'],
              dtype='datetime64[ns]', freq='3M')
  Specify tz to set the timezone.
>>> pd.date_range(start='1/1/2018', periods=5, tz='Asia/Tokyo')
DatetimeIndex(['2018-01-01 00:00:00+09:00', '2018-01-02 00:00:00+09:00',
               '2018-01-03 00:00:00+09:00', '2018-01-04 00:00:00+09:00',
               '2018-01-05 00:00:00+09:00'],
              dtype='datetime64[ns, Asia/Tokyo]', freq='D')
  inclusive controls whether to include start and end that are on the boundary. The default, “both”, includes boundary points on either end.
>>> pd.date_range(start='2017-01-01', end='2017-01-04', inclusive="both")
DatetimeIndex(['2017-01-01', '2017-01-02', '2017-01-03', '2017-01-04'],
              dtype='datetime64[ns]', freq='D')
  Use inclusive='left' to exclude end if it falls on the boundary.
>>> pd.date_range(start='2017-01-01', end='2017-01-04', inclusive='left')
DatetimeIndex(['2017-01-01', '2017-01-02', '2017-01-03'],
              dtype='datetime64[ns]', freq='D')
  Use inclusive='right' to exclude start if it falls on the boundary, and similarly inclusive='neither' will exclude both start and end.
>>> pd.date_range(start='2017-01-01', end='2017-01-04', inclusive='right')
DatetimeIndex(['2017-01-02', '2017-01-03', '2017-01-04'],
              dtype='datetime64[ns]', freq='D')


pandas.DatetimeIndex   classpandas.DatetimeIndex(data=None, freq=NoDefault.no_default, tz=None, normalize=False, closed=None, ambiguous='raise', dayfirst=False, yearfirst=False, dtype=None, copy=False, name=None)[source]

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.  Parameters

data:array-like (1-dimensional), optional

Optional 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.
closed:{‘left’, ‘right’}, optional

Set whether to include start and end that are on the boundary. The default includes boundary points on either end.
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.      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. 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 timezone information.
dayofyear The ordinal day of the year.
day_of_year The ordinal day of the year.
weekofyear (DEPRECATED) The week ordinal of the year.
week (DEPRECATED) The week ordinal 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.
freq Return the frequency object if it is set, otherwise None.
freqstr Return the frequency object as a string if its 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 guess, generated by infer_freq.    Methods
normalize(*args, **kwargs) Convert times to midnight.
strftime(*args, **kwargs) 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/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(*args, **kwargs) Return Datetime Array/Index as object ndarray of datetime.datetime objects.
to_series([keep_tz, index, name]) Create a Series with both index and values equal to the index keys useful with map for returning an indexer based on an index.
to_frame([index, name]) Create a DataFrame with a column containing the Index.
month_name(*args, **kwargs) Return the month names of the DateTimeIndex with specified locale.
day_name(*args, **kwargs) Return the day names of the DateTimeIndex with specified locale.
mean(*args, **kwargs) Return the mean value of the Array.
std(*args, **kwargs) Return sample standard deviation over requested axis.


pandas.DatetimeIndex.ceil   DatetimeIndex.ceil(*args, **kwargs)[source]

Perform ceil operation on the data to the specified freq.  Parameters

freq:str or Offset

The frequency level to ceil the index to. Must be a fixed frequency like ‘S’ (second) not ‘ME’ (month end). See frequency aliases for a list of possible freq values.
ambiguous:‘infer’, bool-ndarray, ‘NaT’, default ‘raise’

Only relevant for DatetimeIndex:  ‘infer’ will attempt to infer fall dst-transition hours based on order bool-ndarray where True signifies a DST time, False designates 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.
nonexistent:‘shift_forward’, ‘shift_backward’, ‘NaT’, timedelta, default ‘raise’

A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST.  ‘shift_forward’ will shift the nonexistent time forward to the closest existing time ‘shift_backward’ will shift the nonexistent time backward to the closest existing time ‘NaT’ will return NaT where there are nonexistent times timedelta objects will shift nonexistent times by the timedelta ‘raise’ will raise an NonExistentTimeError if there are nonexistent times.     Returns
 DatetimeIndex, TimedeltaIndex, or Series

Index of the same type for a DatetimeIndex or TimedeltaIndex, or a Series with the same index for a Series.    Raises
 ValueError if the freq cannot be converted.
   Notes If the timestamps have a timezone, ceiling will take place relative to the local (“wall”) time and re-localized to the same timezone. When ceiling near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples DatetimeIndex
>>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min')
>>> rng
DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00',
               '2018-01-01 12:01:00'],
              dtype='datetime64[ns]', freq='T')
>>> rng.ceil('H')
DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
               '2018-01-01 13:00:00'],
              dtype='datetime64[ns]', freq=None)
  Series
>>> pd.Series(rng).dt.ceil("H")
0   2018-01-01 12:00:00
1   2018-01-01 12:00:00
2   2018-01-01 13:00:00
dtype: datetime64[ns]
  When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized.
>>> rng_tz = pd.DatetimeIndex(["2021-10-31 01:30:00"], tz="Europe/Amsterdam")

>>> rng_tz.ceil("H", ambiguous=False)
DatetimeIndex(['2021-10-31 02:00:00+01:00'],
              dtype='datetime64[ns, Europe/Amsterdam]', freq=None)

>>> rng_tz.ceil("H", ambiguous=True)
DatetimeIndex(['2021-10-31 02:00:00+02:00'],
              dtype='datetime64[ns, Europe/Amsterdam]', freq=None)


pandas.DatetimeIndex.date   propertyDatetimeIndex.date

Returns numpy array of python datetime.date objects. Namely, the date part of Timestamps without time and timezone information.


pandas.DatetimeIndex.day   propertyDatetimeIndex.day

The day of the datetime. Examples
>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="D")
... )
>>> datetime_series
0   2000-01-01
1   2000-01-02
2   2000-01-03
dtype: datetime64[ns]
>>> datetime_series.dt.day
0    1
1    2
2    3
dtype: int64


pandas.DatetimeIndex.day_name   DatetimeIndex.day_name(*args, **kwargs)[source]

Return the day names of the DateTimeIndex with specified locale.  Parameters

locale:str, optional

Locale determining the language in which to return the day name. Default is English locale.    Returns
 Index

Index of day names.     Examples
>>> idx = pd.date_range(start='2018-01-01', freq='D', periods=3)
>>> idx
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
              dtype='datetime64[ns]', freq='D')
>>> idx.day_name()
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='object')


pandas.DatetimeIndex.day_of_week   propertyDatetimeIndex.day_of_week

The day of the week with Monday=0, Sunday=6. Return the day of the week. It is assumed the week starts on Monday, which is denoted by 0 and ends on Sunday which is denoted by 6. This method is available on both Series with datetime values (using the dt accessor) or DatetimeIndex.  Returns
 Series or Index

Containing integers indicating the day number.      See also  Series.dt.dayofweek

Alias.  Series.dt.weekday

Alias.  Series.dt.day_name

Returns the name of the day of the week.    Examples
>>> s = pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series()
>>> s.dt.dayofweek
2016-12-31    5
2017-01-01    6
2017-01-02    0
2017-01-03    1
2017-01-04    2
2017-01-05    3
2017-01-06    4
2017-01-07    5
2017-01-08    6
Freq: D, dtype: int64


pandas.DatetimeIndex.day_of_year   propertyDatetimeIndex.day_of_year

The ordinal day of the year.


pandas.DatetimeIndex.dayofweek   propertyDatetimeIndex.dayofweek

The day of the week with Monday=0, Sunday=6. Return the day of the week. It is assumed the week starts on Monday, which is denoted by 0 and ends on Sunday which is denoted by 6. This method is available on both Series with datetime values (using the dt accessor) or DatetimeIndex.  Returns
 Series or Index

Containing integers indicating the day number.      See also  Series.dt.dayofweek

Alias.  Series.dt.weekday

Alias.  Series.dt.day_name

Returns the name of the day of the week.    Examples
>>> s = pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series()
>>> s.dt.dayofweek
2016-12-31    5
2017-01-01    6
2017-01-02    0
2017-01-03    1
2017-01-04    2
2017-01-05    3
2017-01-06    4
2017-01-07    5
2017-01-08    6
Freq: D, dtype: int64


pandas.DatetimeIndex.dayofyear   propertyDatetimeIndex.dayofyear

The ordinal day of the year.


pandas.DatetimeIndex.floor   DatetimeIndex.floor(*args, **kwargs)[source]

Perform floor operation on the data to the specified freq.  Parameters

freq:str or Offset

The frequency level to floor the index to. Must be a fixed frequency like ‘S’ (second) not ‘ME’ (month end). See frequency aliases for a list of possible freq values.
ambiguous:‘infer’, bool-ndarray, ‘NaT’, default ‘raise’

Only relevant for DatetimeIndex:  ‘infer’ will attempt to infer fall dst-transition hours based on order bool-ndarray where True signifies a DST time, False designates 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.
nonexistent:‘shift_forward’, ‘shift_backward’, ‘NaT’, timedelta, default ‘raise’

A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST.  ‘shift_forward’ will shift the nonexistent time forward to the closest existing time ‘shift_backward’ will shift the nonexistent time backward to the closest existing time ‘NaT’ will return NaT where there are nonexistent times timedelta objects will shift nonexistent times by the timedelta ‘raise’ will raise an NonExistentTimeError if there are nonexistent times.     Returns
 DatetimeIndex, TimedeltaIndex, or Series

Index of the same type for a DatetimeIndex or TimedeltaIndex, or a Series with the same index for a Series.    Raises
 ValueError if the freq cannot be converted.
   Notes If the timestamps have a timezone, flooring will take place relative to the local (“wall”) time and re-localized to the same timezone. When flooring near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples DatetimeIndex
>>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min')
>>> rng
DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00',
               '2018-01-01 12:01:00'],
              dtype='datetime64[ns]', freq='T')
>>> rng.floor('H')
DatetimeIndex(['2018-01-01 11:00:00', '2018-01-01 12:00:00',
               '2018-01-01 12:00:00'],
              dtype='datetime64[ns]', freq=None)
  Series
>>> pd.Series(rng).dt.floor("H")
0   2018-01-01 11:00:00
1   2018-01-01 12:00:00
2   2018-01-01 12:00:00
dtype: datetime64[ns]
  When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized.
>>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam")

>>> rng_tz.floor("2H", ambiguous=False)
DatetimeIndex(['2021-10-31 02:00:00+01:00'],
             dtype='datetime64[ns, Europe/Amsterdam]', freq=None)

>>> rng_tz.floor("2H", ambiguous=True)
DatetimeIndex(['2021-10-31 02:00:00+02:00'],
              dtype='datetime64[ns, Europe/Amsterdam]', freq=None)


pandas.DatetimeIndex.freq   propertyDatetimeIndex.freq

Return the frequency object if it is set, otherwise None.


pandas.DatetimeIndex.freqstr   propertyDatetimeIndex.freqstr

Return the frequency object as a string if its set, otherwise None.


pandas.DatetimeIndex.hour   propertyDatetimeIndex.hour

The hours of the datetime. Examples
>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="h")
... )
>>> datetime_series
0   2000-01-01 00:00:00
1   2000-01-01 01:00:00
2   2000-01-01 02:00:00
dtype: datetime64[ns]
>>> datetime_series.dt.hour
0    0
1    1
2    2
dtype: int64


pandas.DatetimeIndex.indexer_at_time   DatetimeIndex.indexer_at_time(time, asof=False)[source]

Return index locations of values at particular time of day (e.g. 9:30AM).  Parameters

time:datetime.time or str

Time passed in either as object (datetime.time) or as string in appropriate format (“%H:%M”, “%H%M”, “%I:%M%p”, “%I%M%p”, “%H:%M:%S”, “%H%M%S”, “%I:%M:%S%p”, “%I%M%S%p”).    Returns
 np.ndarray[np.intp]
    See also  indexer_between_time

Get index locations of values between particular times of day.  DataFrame.at_time

Select values at particular time of day.


pandas.DatetimeIndex.indexer_between_time   DatetimeIndex.indexer_between_time(start_time, end_time, include_start=True, include_end=True)[source]

Return index locations of values between particular times of day (e.g., 9:00-9:30AM).  Parameters

start_time, end_time:datetime.time, str

Time passed either as object (datetime.time) or as string in appropriate format (“%H:%M”, “%H%M”, “%I:%M%p”, “%I%M%p”, “%H:%M:%S”, “%H%M%S”, “%I:%M:%S%p”,”%I%M%S%p”).
include_start:bool, default True

include_end:bool, default True

  Returns
 np.ndarray[np.intp]
    See also  indexer_at_time

Get index locations of values at particular time of day.  DataFrame.between_time

Select values between particular times of day.


pandas.DatetimeIndex.inferred_freq   DatetimeIndex.inferred_freq

Tries to return a string representing a frequency guess, generated by infer_freq. Returns None if it can’t autodetect the frequency.


pandas.DatetimeIndex.is_leap_year   propertyDatetimeIndex.is_leap_year

Boolean indicator if the date belongs to a leap year. A leap year is a year, which has 366 days (instead of 365) including 29th of February as an intercalary day. Leap years are years which are multiples of four with the exception of years divisible by 100 but not by 400.  Returns
 Series or ndarray

Booleans indicating if dates belong to a leap year.     Examples This method is available on Series with datetime values under the .dt accessor, and directly on DatetimeIndex.
>>> idx = pd.date_range("2012-01-01", "2015-01-01", freq="Y")
>>> idx
DatetimeIndex(['2012-12-31', '2013-12-31', '2014-12-31'],
              dtype='datetime64[ns]', freq='A-DEC')
>>> idx.is_leap_year
array([ True, False, False])

>>> dates_series = pd.Series(idx)
>>> dates_series
0   2012-12-31
1   2013-12-31
2   2014-12-31
dtype: datetime64[ns]
>>> dates_series.dt.is_leap_year
0     True
1    False
2    False
dtype: bool


pandas.DatetimeIndex.is_month_end   propertyDatetimeIndex.is_month_end

Indicates whether the date is the last day of the month.  Returns
 Series or array

For Series, returns a Series with boolean values. For DatetimeIndex, returns a boolean array.      See also  is_month_start

Return a boolean indicating whether the date is the first day of the month.  is_month_end

Return a boolean indicating whether the date is the last day of the month.    Examples This method is available on Series with datetime values under the .dt accessor, and directly on DatetimeIndex.
>>> s = pd.Series(pd.date_range("2018-02-27", periods=3))
>>> s
0   2018-02-27
1   2018-02-28
2   2018-03-01
dtype: datetime64[ns]
>>> s.dt.is_month_start
0    False
1    False
2    True
dtype: bool
>>> s.dt.is_month_end
0    False
1    True
2    False
dtype: bool

>>> idx = pd.date_range("2018-02-27", periods=3)
>>> idx.is_month_start
array([False, False, True])
>>> idx.is_month_end
array([False, True, False])


pandas.DatetimeIndex.is_month_start   propertyDatetimeIndex.is_month_start

Indicates whether the date is the first day of the month.  Returns
 Series or array

For Series, returns a Series with boolean values. For DatetimeIndex, returns a boolean array.      See also  is_month_start

Return a boolean indicating whether the date is the first day of the month.  is_month_end

Return a boolean indicating whether the date is the last day of the month.    Examples This method is available on Series with datetime values under the .dt accessor, and directly on DatetimeIndex.
>>> s = pd.Series(pd.date_range("2018-02-27", periods=3))
>>> s
0   2018-02-27
1   2018-02-28
2   2018-03-01
dtype: datetime64[ns]
>>> s.dt.is_month_start
0    False
1    False
2    True
dtype: bool
>>> s.dt.is_month_end
0    False
1    True
2    False
dtype: bool

>>> idx = pd.date_range("2018-02-27", periods=3)
>>> idx.is_month_start
array([False, False, True])
>>> idx.is_month_end
array([False, True, False])


pandas.DatetimeIndex.is_quarter_end   propertyDatetimeIndex.is_quarter_end

Indicator for whether the date is the last day of a quarter.  Returns

is_quarter_end:Series or DatetimeIndex

The same type as the original data with boolean values. Series will have the same name and index. DatetimeIndex will have the same name.      See also  quarter

Return the quarter of the date.  is_quarter_start

Similar property indicating the quarter start.    Examples This method is available on Series with datetime values under the .dt accessor, and directly on DatetimeIndex.
>>> df = pd.DataFrame({'dates': pd.date_range("2017-03-30",
...                    periods=4)})
>>> df.assign(quarter=df.dates.dt.quarter,
...           is_quarter_end=df.dates.dt.is_quarter_end)
       dates  quarter    is_quarter_end
0 2017-03-30        1             False
1 2017-03-31        1              True
2 2017-04-01        2             False
3 2017-04-02        2             False

>>> idx = pd.date_range('2017-03-30', periods=4)
>>> idx
DatetimeIndex(['2017-03-30', '2017-03-31', '2017-04-01', '2017-04-02'],
              dtype='datetime64[ns]', freq='D')

>>> idx.is_quarter_end
array([False,  True, False, False])


pandas.DatetimeIndex.is_quarter_start   propertyDatetimeIndex.is_quarter_start

Indicator for whether the date is the first day of a quarter.  Returns

is_quarter_start:Series or DatetimeIndex

The same type as the original data with boolean values. Series will have the same name and index. DatetimeIndex will have the same name.      See also  quarter

Return the quarter of the date.  is_quarter_end

Similar property for indicating the quarter start.    Examples This method is available on Series with datetime values under the .dt accessor, and directly on DatetimeIndex.
>>> df = pd.DataFrame({'dates': pd.date_range("2017-03-30",
...                   periods=4)})
>>> df.assign(quarter=df.dates.dt.quarter,
...           is_quarter_start=df.dates.dt.is_quarter_start)
       dates  quarter  is_quarter_start
0 2017-03-30        1             False
1 2017-03-31        1             False
2 2017-04-01        2              True
3 2017-04-02        2             False

>>> idx = pd.date_range('2017-03-30', periods=4)
>>> idx
DatetimeIndex(['2017-03-30', '2017-03-31', '2017-04-01', '2017-04-02'],
              dtype='datetime64[ns]', freq='D')

>>> idx.is_quarter_start
array([False, False,  True, False])


pandas.DatetimeIndex.is_year_end   propertyDatetimeIndex.is_year_end

Indicate whether the date is the last day of the year.  Returns
 Series or DatetimeIndex

The same type as the original data with boolean values. Series will have the same name and index. DatetimeIndex will have the same name.      See also  is_year_start

Similar property indicating the start of the year.    Examples This method is available on Series with datetime values under the .dt accessor, and directly on DatetimeIndex.
>>> dates = pd.Series(pd.date_range("2017-12-30", periods=3))
>>> dates
0   2017-12-30
1   2017-12-31
2   2018-01-01
dtype: datetime64[ns]

>>> dates.dt.is_year_end
0    False
1     True
2    False
dtype: bool

>>> idx = pd.date_range("2017-12-30", periods=3)
>>> idx
DatetimeIndex(['2017-12-30', '2017-12-31', '2018-01-01'],
              dtype='datetime64[ns]', freq='D')

>>> idx.is_year_end
array([False,  True, False])


pandas.DatetimeIndex.is_year_start   propertyDatetimeIndex.is_year_start

Indicate whether the date is the first day of a year.  Returns
 Series or DatetimeIndex

The same type as the original data with boolean values. Series will have the same name and index. DatetimeIndex will have the same name.      See also  is_year_end

Similar property indicating the last day of the year.    Examples This method is available on Series with datetime values under the .dt accessor, and directly on DatetimeIndex.
>>> dates = pd.Series(pd.date_range("2017-12-30", periods=3))
>>> dates
0   2017-12-30
1   2017-12-31
2   2018-01-01
dtype: datetime64[ns]

>>> dates.dt.is_year_start
0    False
1    False
2    True
dtype: bool

>>> idx = pd.date_range("2017-12-30", periods=3)
>>> idx
DatetimeIndex(['2017-12-30', '2017-12-31', '2018-01-01'],
              dtype='datetime64[ns]', freq='D')

>>> idx.is_year_start
array([False, False,  True])


pandas.DatetimeIndex.mean   DatetimeIndex.mean(*args, **kwargs)[source]

Return the mean value of the Array.  New in version 0.25.0.   Parameters

skipna:bool, default True

Whether to ignore any NaT elements.
axis:int, optional, default 0

  Returns
 scalar

Timestamp or Timedelta.      See also  numpy.ndarray.mean

Returns the average of array elements along a given axis.  Series.mean

Return the mean value in a Series.    Notes mean is only defined for Datetime and Timedelta dtypes, not for Period.


pandas.DatetimeIndex.microsecond   propertyDatetimeIndex.microsecond

The microseconds of the datetime. Examples
>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="us")
... )
>>> datetime_series
0   2000-01-01 00:00:00.000000
1   2000-01-01 00:00:00.000001
2   2000-01-01 00:00:00.000002
dtype: datetime64[ns]
>>> datetime_series.dt.microsecond
0       0
1       1
2       2
dtype: int64


pandas.DatetimeIndex.minute   propertyDatetimeIndex.minute

The minutes of the datetime. Examples
>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="T")
... )
>>> datetime_series
0   2000-01-01 00:00:00
1   2000-01-01 00:01:00
2   2000-01-01 00:02:00
dtype: datetime64[ns]
>>> datetime_series.dt.minute
0    0
1    1
2    2
dtype: int64


pandas.DatetimeIndex.month   propertyDatetimeIndex.month

The month as January=1, December=12. Examples
>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="M")
... )
>>> datetime_series
0   2000-01-31
1   2000-02-29
2   2000-03-31
dtype: datetime64[ns]
>>> datetime_series.dt.month
0    1
1    2
2    3
dtype: int64


pandas.DatetimeIndex.month_name   DatetimeIndex.month_name(*args, **kwargs)[source]

Return the month names of the DateTimeIndex with specified locale.  Parameters

locale:str, optional

Locale determining the language in which to return the month name. Default is English locale.    Returns
 Index

Index of month names.     Examples
>>> idx = pd.date_range(start='2018-01', freq='M', periods=3)
>>> idx
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
              dtype='datetime64[ns]', freq='M')
>>> idx.month_name()
Index(['January', 'February', 'March'], dtype='object')


pandas.DatetimeIndex.nanosecond   propertyDatetimeIndex.nanosecond

The nanoseconds of the datetime. Examples
>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="ns")
... )
>>> datetime_series
0   2000-01-01 00:00:00.000000000
1   2000-01-01 00:00:00.000000001
2   2000-01-01 00:00:00.000000002
dtype: datetime64[ns]
>>> datetime_series.dt.nanosecond
0       0
1       1
2       2
dtype: int64


pandas.DatetimeIndex.normalize   DatetimeIndex.normalize(*args, **kwargs)[source]

Convert times to midnight. The time component of the date-time is converted to midnight i.e. 00:00:00. This is useful in cases, when the time does not matter. Length is unaltered. The timezones are unaffected. This method is available on Series with datetime values under the .dt accessor, and directly on Datetime Array/Index.  Returns
 DatetimeArray, DatetimeIndex or Series

The same type as the original data. Series will have the same name and index. DatetimeIndex will have the same name.      See also  floor

Floor the datetimes to the specified freq.  ceil

Ceil the datetimes to the specified freq.  round

Round the datetimes to the specified freq.    Examples
>>> idx = pd.date_range(start='2014-08-01 10:00', freq='H',
...                     periods=3, tz='Asia/Calcutta')
>>> idx
DatetimeIndex(['2014-08-01 10:00:00+05:30',
               '2014-08-01 11:00:00+05:30',
               '2014-08-01 12:00:00+05:30'],
                dtype='datetime64[ns, Asia/Calcutta]', freq='H')
>>> idx.normalize()
DatetimeIndex(['2014-08-01 00:00:00+05:30',
               '2014-08-01 00:00:00+05:30',
               '2014-08-01 00:00:00+05:30'],
               dtype='datetime64[ns, Asia/Calcutta]', freq=None)


pandas.DatetimeIndex.quarter   propertyDatetimeIndex.quarter

The quarter of the date.


pandas.DatetimeIndex.round   DatetimeIndex.round(*args, **kwargs)[source]

Perform round operation on the data to the specified freq.  Parameters

freq:str or Offset

The frequency level to round the index to. Must be a fixed frequency like ‘S’ (second) not ‘ME’ (month end). See frequency aliases for a list of possible freq values.
ambiguous:‘infer’, bool-ndarray, ‘NaT’, default ‘raise’

Only relevant for DatetimeIndex:  ‘infer’ will attempt to infer fall dst-transition hours based on order bool-ndarray where True signifies a DST time, False designates 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.
nonexistent:‘shift_forward’, ‘shift_backward’, ‘NaT’, timedelta, default ‘raise’

A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST.  ‘shift_forward’ will shift the nonexistent time forward to the closest existing time ‘shift_backward’ will shift the nonexistent time backward to the closest existing time ‘NaT’ will return NaT where there are nonexistent times timedelta objects will shift nonexistent times by the timedelta ‘raise’ will raise an NonExistentTimeError if there are nonexistent times.     Returns
 DatetimeIndex, TimedeltaIndex, or Series

Index of the same type for a DatetimeIndex or TimedeltaIndex, or a Series with the same index for a Series.    Raises
 ValueError if the freq cannot be converted.
   Notes If the timestamps have a timezone, rounding will take place relative to the local (“wall”) time and re-localized to the same timezone. When rounding near daylight savings time, use nonexistent and ambiguous to control the re-localization behavior. Examples DatetimeIndex
>>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min')
>>> rng
DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00',
               '2018-01-01 12:01:00'],
              dtype='datetime64[ns]', freq='T')
>>> rng.round('H')
DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
               '2018-01-01 12:00:00'],
              dtype='datetime64[ns]', freq=None)
  Series
>>> pd.Series(rng).dt.round("H")
0   2018-01-01 12:00:00
1   2018-01-01 12:00:00
2   2018-01-01 12:00:00
dtype: datetime64[ns]
  When rounding near a daylight savings time transition, use ambiguous or nonexistent to control how the timestamp should be re-localized.
>>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam")

>>> rng_tz.floor("2H", ambiguous=False)
DatetimeIndex(['2021-10-31 02:00:00+01:00'],
              dtype='datetime64[ns, Europe/Amsterdam]', freq=None)

>>> rng_tz.floor("2H", ambiguous=True)
DatetimeIndex(['2021-10-31 02:00:00+02:00'],
              dtype='datetime64[ns, Europe/Amsterdam]', freq=None)


pandas.DatetimeIndex.second   propertyDatetimeIndex.second

The seconds of the datetime. Examples
>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="s")
... )
>>> datetime_series
0   2000-01-01 00:00:00
1   2000-01-01 00:00:01
2   2000-01-01 00:00:02
dtype: datetime64[ns]
>>> datetime_series.dt.second
0    0
1    1
2    2
dtype: int64


pandas.DatetimeIndex.snap   DatetimeIndex.snap(freq='S')[source]

Snap time stamps to nearest occurring frequency.  Returns
 DatetimeIndex


pandas.DatetimeIndex.std   DatetimeIndex.std(*args, **kwargs)[source]

Return sample standard deviation over requested axis. Normalized by N-1 by default. This can be changed using the ddof argument  Parameters

axis:int optional, default None

Axis for the function to be applied on.
ddof:int, default 1

Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
skipna:bool, default True

Exclude NA/null values. If an entire row/column is NA, the result will be NA.    Returns
 Timedelta


pandas.DatetimeIndex.strftime   DatetimeIndex.strftime(*args, **kwargs)[source]

Convert to Index using specified date_format. Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in python string format doc.  Parameters

date_format:str

Date format string (e.g. “%Y-%m-%d”).    Returns
 ndarray[object]

NumPy ndarray of formatted strings.      See also  to_datetime

Convert the given argument to datetime.  DatetimeIndex.normalize

Return DatetimeIndex with times to midnight.  DatetimeIndex.round

Round the DatetimeIndex to the specified freq.  DatetimeIndex.floor

Floor the DatetimeIndex to the specified freq.    Examples
>>> rng = pd.date_range(pd.Timestamp("2018-03-10 09:00"),
...                     periods=3, freq='s')
>>> rng.strftime('%B %d, %Y, %r')
Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM',
       'March 10, 2018, 09:00:02 AM'],
      dtype='object')


pandas.DatetimeIndex.time   propertyDatetimeIndex.time

Returns numpy array of datetime.time objects. The time part of the Timestamps.


pandas.DatetimeIndex.timetz   propertyDatetimeIndex.timetz

Returns numpy array of datetime.time objects with timezone information. The time part of the Timestamps.


pandas.DatetimeIndex.to_frame   DatetimeIndex.to_frame(index=True, name=NoDefault.no_default)[source]

Create a DataFrame with a column containing the Index.  Parameters

index:bool, default True

Set the index of the returned DataFrame as the original Index.
name:object, default None

The passed name should substitute for the index name (if it has one).    Returns
 DataFrame

DataFrame containing the original Index data.      See also  Index.to_series

Convert an Index to a Series.  Series.to_frame

Convert Series to DataFrame.    Examples
>>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal')
>>> idx.to_frame()
       animal
animal
Ant       Ant
Bear     Bear
Cow       Cow
  By default, the original Index is reused. To enforce a new Index:
>>> idx.to_frame(index=False)
    animal
0   Ant
1  Bear
2   Cow
  To override the name of the resulting column, specify name:
>>> idx.to_frame(index=False, name='zoo')
    zoo
0   Ant
1  Bear
2   Cow


pandas.DatetimeIndex.to_period   DatetimeIndex.to_period(*args, **kwargs)[source]

Cast to PeriodArray/Index at a particular frequency. Converts DatetimeArray/Index to PeriodArray/Index.  Parameters

freq:str or Offset, optional

One of pandas’ offset strings or an Offset object. Will be inferred by default.    Returns
 PeriodArray/Index
  Raises
 ValueError

When converting a DatetimeArray/Index with non-regular values, so that a frequency cannot be inferred.      See also  PeriodIndex

Immutable ndarray holding ordinal values.  DatetimeIndex.to_pydatetime

Return DatetimeIndex as object.    Examples
>>> df = pd.DataFrame({"y": [1, 2, 3]},
...                   index=pd.to_datetime(["2000-03-31 00:00:00",
...                                         "2000-05-31 00:00:00",
...                                         "2000-08-31 00:00:00"]))
>>> df.index.to_period("M")
PeriodIndex(['2000-03', '2000-05', '2000-08'],
            dtype='period[M]')
  Infer the daily frequency
>>> idx = pd.date_range("2017-01-01", periods=2)
>>> idx.to_period()
PeriodIndex(['2017-01-01', '2017-01-02'],
            dtype='period[D]')


pandas.DatetimeIndex.to_perioddelta   DatetimeIndex.to_perioddelta(freq)[source]

Calculate TimedeltaArray of difference between index values and index converted to PeriodArray at specified freq. Used for vectorized offsets.  Parameters

freq:Period frequency

  Returns
 TimedeltaArray/Index


pandas.DatetimeIndex.to_pydatetime   DatetimeIndex.to_pydatetime(*args, **kwargs)[source]

Return Datetime Array/Index as object ndarray of datetime.datetime objects.  Returns

datetimes:ndarray[object]


pandas.DatetimeIndex.to_series   DatetimeIndex.to_series(keep_tz=NoDefault.no_default, index=None, name=None)[source]

Create a Series with both index and values equal to the index keys useful with map for returning an indexer based on an index.  Parameters

keep_tz:optional, defaults True

Return the data keeping the timezone. If keep_tz is True:
If the timezone is not set, the resulting Series will have a datetime64[ns] dtype. Otherwise the Series will have an datetime64[ns, tz] dtype; the tz will be preserved.
 If keep_tz is False:
Series will have a datetime64[ns] dtype. TZ aware objects will have the tz removed.
  Changed in version 1.0.0: The default value is now True. In a future version, this keyword will be removed entirely. Stop passing the argument to obtain the future behavior and silence the warning.
index:Index, optional

Index of resulting Series. If None, defaults to original index.
name:str, optional

Name of resulting Series. If None, defaults to name of original index.    Returns
 Series


pandas.DatetimeIndex.tz   propertyDatetimeIndex.tz

Return the timezone.  Returns
 datetime.tzinfo, pytz.tzinfo.BaseTZInfo, dateutil.tz.tz.tzfile, or None

Returns None when the array is tz-naive.


pandas.DatetimeIndex.tz_convert   DatetimeIndex.tz_convert(tz)[source]

Convert tz-aware Datetime Array/Index from one time zone to another.  Parameters

tz:str, pytz.timezone, dateutil.tz.tzfile or None

Time zone for time. Corresponding timestamps would be converted to this time zone of the Datetime Array/Index. A tz of None will convert to UTC and remove the timezone information.    Returns
 Array or Index
  Raises
 TypeError

If Datetime Array/Index is tz-naive.      See also  DatetimeIndex.tz

A timezone that has a variable offset from UTC.  DatetimeIndex.tz_localize

Localize tz-naive DatetimeIndex to a given time zone, or remove timezone from a tz-aware DatetimeIndex.    Examples With the tz parameter, we can change the DatetimeIndex to other time zones:
>>> dti = pd.date_range(start='2014-08-01 09:00',
...                     freq='H', periods=3, tz='Europe/Berlin')

>>> dti
DatetimeIndex(['2014-08-01 09:00:00+02:00',
               '2014-08-01 10:00:00+02:00',
               '2014-08-01 11:00:00+02:00'],
              dtype='datetime64[ns, Europe/Berlin]', freq='H')

>>> dti.tz_convert('US/Central')
DatetimeIndex(['2014-08-01 02:00:00-05:00',
               '2014-08-01 03:00:00-05:00',
               '2014-08-01 04:00:00-05:00'],
              dtype='datetime64[ns, US/Central]', freq='H')
  With the tz=None, we can remove the timezone (after converting to UTC if necessary):
>>> dti = pd.date_range(start='2014-08-01 09:00', freq='H',
...                     periods=3, tz='Europe/Berlin')

>>> dti
DatetimeIndex(['2014-08-01 09:00:00+02:00',
               '2014-08-01 10:00:00+02:00',
               '2014-08-01 11:00:00+02:00'],
                dtype='datetime64[ns, Europe/Berlin]', freq='H')

>>> dti.tz_convert(None)
DatetimeIndex(['2014-08-01 07:00:00',
               '2014-08-01 08:00:00',
               '2014-08-01 09:00:00'],
                dtype='datetime64[ns]', freq='H')


pandas.DatetimeIndex.tz_localize   DatetimeIndex.tz_localize(tz, ambiguous='raise', nonexistent='raise')[source]

Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index. This method takes a time zone (tz) naive Datetime Array/Index object and makes this time zone aware. It does not move the time to another time zone. This method can also be used to do the inverse – to create a time zone unaware object from an aware object. To that end, pass tz=None.  Parameters

tz:str, pytz.timezone, dateutil.tz.tzfile or None

Time zone to convert timestamps to. Passing None will remove the time zone information preserving local time.
ambiguous:‘infer’, ‘NaT’, bool array, 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.
nonexistent:‘shift_forward’, ‘shift_backward, ‘NaT’, timedelta, default ‘raise’

A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST.  ‘shift_forward’ will shift the nonexistent time forward to the closest existing time ‘shift_backward’ will shift the nonexistent time backward to the closest existing time ‘NaT’ will return NaT where there are nonexistent times timedelta objects will shift nonexistent times by the timedelta ‘raise’ will raise an NonExistentTimeError if there are nonexistent times.     Returns
 Same type as self

Array/Index converted to the specified time zone.    Raises
 TypeError

If the Datetime Array/Index is tz-aware and tz is not None.      See also  DatetimeIndex.tz_convert

Convert tz-aware DatetimeIndex from one time zone to another.    Examples
>>> tz_naive = pd.date_range('2018-03-01 09:00', periods=3)
>>> tz_naive
DatetimeIndex(['2018-03-01 09:00:00', '2018-03-02 09:00:00',
               '2018-03-03 09:00:00'],
              dtype='datetime64[ns]', freq='D')
  Localize DatetimeIndex in US/Eastern time zone:
>>> tz_aware = tz_naive.tz_localize(tz='US/Eastern')
>>> tz_aware
DatetimeIndex(['2018-03-01 09:00:00-05:00',
               '2018-03-02 09:00:00-05:00',
               '2018-03-03 09:00:00-05:00'],
              dtype='datetime64[ns, US/Eastern]', freq=None)
  With the tz=None, we can remove the time zone information while keeping the local time (not converted to UTC):
>>> tz_aware.tz_localize(None)
DatetimeIndex(['2018-03-01 09:00:00', '2018-03-02 09:00:00',
               '2018-03-03 09:00:00'],
              dtype='datetime64[ns]', freq=None)
  Be careful with DST changes. When there is sequential data, pandas can infer the DST time:
>>> s = pd.to_datetime(pd.Series(['2018-10-28 01:30:00',
...                               '2018-10-28 02:00:00',
...                               '2018-10-28 02:30:00',
...                               '2018-10-28 02:00:00',
...                               '2018-10-28 02:30:00',
...                               '2018-10-28 03:00:00',
...                               '2018-10-28 03:30:00']))
>>> s.dt.tz_localize('CET', ambiguous='infer')
0   2018-10-28 01:30:00+02:00
1   2018-10-28 02:00:00+02:00
2   2018-10-28 02:30:00+02:00
3   2018-10-28 02:00:00+01:00
4   2018-10-28 02:30:00+01:00
5   2018-10-28 03:00:00+01:00
6   2018-10-28 03:30:00+01:00
dtype: datetime64[ns, CET]
  In some cases, inferring the DST is impossible. In such cases, you can pass an ndarray to the ambiguous parameter to set the DST explicitly
>>> s = pd.to_datetime(pd.Series(['2018-10-28 01:20:00',
...                               '2018-10-28 02:36:00',
...                               '2018-10-28 03:46:00']))
>>> s.dt.tz_localize('CET', ambiguous=np.array([True, True, False]))
0   2018-10-28 01:20:00+02:00
1   2018-10-28 02:36:00+02:00
2   2018-10-28 03:46:00+01:00
dtype: datetime64[ns, CET]
  If the DST transition causes nonexistent times, you can shift these dates forward or backwards with a timedelta object or ‘shift_forward’ or ‘shift_backwards’.
>>> s = pd.to_datetime(pd.Series(['2015-03-29 02:30:00',
...                               '2015-03-29 03:30:00']))
>>> s.dt.tz_localize('Europe/Warsaw', nonexistent='shift_forward')
0   2015-03-29 03:00:00+02:00
1   2015-03-29 03:30:00+02:00
dtype: datetime64[ns, Europe/Warsaw]

>>> s.dt.tz_localize('Europe/Warsaw', nonexistent='shift_backward')
0   2015-03-29 01:59:59.999999999+01:00
1   2015-03-29 03:30:00+02:00
dtype: datetime64[ns, Europe/Warsaw]

>>> s.dt.tz_localize('Europe/Warsaw', nonexistent=pd.Timedelta('1H'))
0   2015-03-29 03:30:00+02:00
1   2015-03-29 03:30:00+02:00
dtype: datetime64[ns, Europe/Warsaw]


pandas.DatetimeIndex.week   propertyDatetimeIndex.week

The week ordinal of the year.  Deprecated since version 1.1.0.  weekofyear and week have been deprecated. Please use DatetimeIndex.isocalendar().week instead.


pandas.DatetimeIndex.weekday   propertyDatetimeIndex.weekday

The day of the week with Monday=0, Sunday=6. Return the day of the week. It is assumed the week starts on Monday, which is denoted by 0 and ends on Sunday which is denoted by 6. This method is available on both Series with datetime values (using the dt accessor) or DatetimeIndex.  Returns
 Series or Index

Containing integers indicating the day number.      See also  Series.dt.dayofweek

Alias.  Series.dt.weekday

Alias.  Series.dt.day_name

Returns the name of the day of the week.    Examples
>>> s = pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series()
>>> s.dt.dayofweek
2016-12-31    5
2017-01-01    6
2017-01-02    0
2017-01-03    1
2017-01-04    2
2017-01-05    3
2017-01-06    4
2017-01-07    5
2017-01-08    6
Freq: D, dtype: int64


pandas.DatetimeIndex.weekofyear   propertyDatetimeIndex.weekofyear

The week ordinal of the year.  Deprecated since version 1.1.0.  weekofyear and week have been deprecated. Please use DatetimeIndex.isocalendar().week instead.


pandas.DatetimeIndex.year   propertyDatetimeIndex.year

The year of the datetime. Examples
>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="Y")
... )
>>> datetime_series
0   2000-12-31
1   2001-12-31
2   2002-12-31
dtype: datetime64[ns]
>>> datetime_series.dt.year
0    2000
1    2001
2    2002
dtype: int64


pandas.DatetimeTZDtype   classpandas.DatetimeTZDtype(unit='ns', tz=None)[source]

An ExtensionDtype for timezone-aware datetime data. This is not an actual numpy dtype, but a duck type.  Parameters

unit:str, default “ns”

The precision of the datetime data. Currently limited to "ns".
tz:str, int, or datetime.tzinfo

The timezone.    Raises
 pytz.UnknownTimeZoneError

When the requested timezone cannot be found.     Examples
>>> pd.DatetimeTZDtype(tz='UTC')
datetime64[ns, UTC]

>>> pd.DatetimeTZDtype(tz='dateutil/US/Central')
datetime64[ns, tzfile('/usr/share/zoneinfo/US/Central')]
  Attributes
unit The precision of the datetime data.
tz The timezone.    Methods
None


pandas.DatetimeTZDtype.tz   propertyDatetimeTZDtype.tz

The timezone.


pandas.DatetimeTZDtype.unit   propertyDatetimeTZDtype.unit

The precision of the datetime data.


pandas.describe_option   pandas.describe_option(pat, _print_desc=False)=<pandas._config.config.CallableDynamicDoc object>

Prints the description for one or more registered options. Call with no arguments to get a listing for all registered options. Available options:  compute.[use_bottleneck, use_numba, use_numexpr] display.[chop_threshold, colheader_justify, column_space, date_dayfirst, date_yearfirst, encoding, expand_frame_repr, float_format] display.html.[border, table_schema, use_mathjax] display.[large_repr] display.latex.[escape, longtable, multicolumn, multicolumn_format, multirow, repr] display.[max_categories, max_columns, max_colwidth, max_dir_items, max_info_columns, max_info_rows, max_rows, max_seq_items, memory_usage, min_rows, multi_sparse, notebook_repr_html, pprint_nest_depth, precision, show_dimensions] display.unicode.[ambiguous_as_wide, east_asian_width] display.[width] io.excel.ods.[reader, writer] io.excel.xls.[reader, writer] io.excel.xlsb.[reader] io.excel.xlsm.[reader, writer] io.excel.xlsx.[reader, writer] io.hdf.[default_format, dropna_table] io.parquet.[engine] io.sql.[engine] mode.[chained_assignment, data_manager, sim_interactive, string_storage, use_inf_as_na, use_inf_as_null] plotting.[backend] plotting.matplotlib.[register_converters] styler.format.[decimal, escape, formatter, na_rep, precision, thousands] styler.html.[mathjax] styler.latex.[environment, hrules, multicol_align, multirow_align] styler.render.[encoding, max_columns, max_elements, max_rows, repr] styler.sparse.[columns, index]   Parameters

pat:str

Regexp pattern. All matching keys will have their description displayed.
_print_desc:bool, default True

If True (default) the description(s) will be printed to stdout. Otherwise, the description(s) will be returned as a unicode string (for testing).    Returns
 None by default, the description(s) as a unicode string if _print_desc
is False
   Notes The available options with its descriptions:  compute.use_bottleneck:bool

Use the bottleneck library to accelerate if it is installed, the default is True Valid values: False,True [default: True] [currently: True]  compute.use_numba:bool

Use the numba engine option for select operations if it is installed, the default is False Valid values: False,True [default: False] [currently: False]  compute.use_numexpr:bool

Use the numexpr library to accelerate computation if it is installed, the default is True Valid values: False,True [default: True] [currently: True]  display.chop_threshold:float or None

if set to a float value, all float values smaller then the given threshold will be displayed as exactly 0 by repr and friends. [default: None] [currently: None]  display.colheader_justify:‘left’/’right’

Controls the justification of column headers. used by DataFrameFormatter. [default: right] [currently: right]  display.column_space No description available.

[default: 12] [currently: 12]  display.date_dayfirst:boolean

When True, prints and parses dates with the day first, eg 20/01/2005 [default: False] [currently: False]  display.date_yearfirst:boolean

When True, prints and parses dates with the year first, eg 2005/01/20 [default: False] [currently: False]  display.encoding:str/unicode

Defaults to the detected encoding of the console. Specifies the encoding to be used for strings returned by to_string, these are generally strings meant to be displayed on the console. [default: utf-8] [currently: utf-8]  display.expand_frame_repr:boolean

Whether to print out the full DataFrame repr for wide DataFrames across multiple lines, max_columns is still respected, but the output will wrap-around across multiple “pages” if its width exceeds display.width. [default: True] [currently: True]  display.float_format:callable

The callable should accept a floating point number and return a string with the desired format of the number. This is used in some places like SeriesFormatter. See formats.format.EngFormatter for an example. [default: None] [currently: None]  display.html.border:int

A border=value attribute is inserted in the <table> tag for the DataFrame HTML repr. [default: 1] [currently: 1]  display.html.table_schema:boolean

Whether to publish a Table Schema representation for frontends that support it. (default: False) [default: False] [currently: False]  display.html.use_mathjax:boolean

When True, Jupyter notebook will process table contents using MathJax, rendering mathematical expressions enclosed by the dollar symbol. (default: True) [default: True] [currently: True]  display.large_repr:‘truncate’/’info’

For DataFrames exceeding max_rows/max_cols, the repr (and HTML repr) can show a truncated table (the default from 0.13), or switch to the view from df.info() (the behaviour in earlier versions of pandas). [default: truncate] [currently: truncate]  display.latex.escape:bool

This specifies if the to_latex method of a Dataframe uses escapes special characters. Valid values: False,True [default: True] [currently: True]  display.latex.longtable :bool

This specifies if the to_latex method of a Dataframe uses the longtable format. Valid values: False,True [default: False] [currently: False]  display.latex.multicolumn:bool

This specifies if the to_latex method of a Dataframe uses multicolumns to pretty-print MultiIndex columns. Valid values: False,True [default: True] [currently: True]  display.latex.multicolumn_format:bool

This specifies if the to_latex method of a Dataframe uses multicolumns to pretty-print MultiIndex columns. Valid values: False,True [default: l] [currently: l]  display.latex.multirow:bool

This specifies if the to_latex method of a Dataframe uses multirows to pretty-print MultiIndex rows. Valid values: False,True [default: False] [currently: False]  display.latex.repr:boolean

Whether to produce a latex DataFrame representation for jupyter environments that support it. (default: False) [default: False] [currently: False]  display.max_categories:int

This sets the maximum number of categories pandas should output when printing out a Categorical or a Series of dtype “category”. [default: 8] [currently: 8]  display.max_columns:int

If max_cols is exceeded, switch to truncate view. Depending on large_repr, objects are either centrally truncated or printed as a summary view. ‘None’ value means unlimited. In case python/IPython is running in a terminal and large_repr equals ‘truncate’ this can be set to 0 and pandas will auto-detect the width of the terminal and print a truncated object which fits the screen width. The IPython notebook, IPython qtconsole, or IDLE do not run in a terminal and hence it is not possible to do correct auto-detection. [default: 0] [currently: 0]  display.max_colwidth:int or None

The maximum width in characters of a column in the repr of a pandas data structure. When the column overflows, a “…” placeholder is embedded in the output. A ‘None’ value means unlimited. [default: 50] [currently: 50]  display.max_dir_items:int

The number of items that will be added to dir(…). ‘None’ value means unlimited. Because dir is cached, changing this option will not immediately affect already existing dataframes until a column is deleted or added. This is for instance used to suggest columns from a dataframe to tab completion. [default: 100] [currently: 100]  display.max_info_columns:int

max_info_columns is used in DataFrame.info method to decide if per column information will be printed. [default: 100] [currently: 100]  display.max_info_rows:int or None

df.info() will usually show null-counts for each column. For large frames this can be quite slow. max_info_rows and max_info_cols limit this null check only to frames with smaller dimensions than specified. [default: 1690785] [currently: 1690785]  display.max_rows:int

If max_rows is exceeded, switch to truncate view. Depending on large_repr, objects are either centrally truncated or printed as a summary view. ‘None’ value means unlimited. In case python/IPython is running in a terminal and large_repr equals ‘truncate’ this can be set to 0 and pandas will auto-detect the height of the terminal and print a truncated object which fits the screen height. The IPython notebook, IPython qtconsole, or IDLE do not run in a terminal and hence it is not possible to do correct auto-detection. [default: 60] [currently: 60]  display.max_seq_items:int or None

When pretty-printing a long sequence, no more then max_seq_items will be printed. If items are omitted, they will be denoted by the addition of “…” to the resulting string. If set to None, the number of items to be printed is unlimited. [default: 100] [currently: 100]  display.memory_usage:bool, string or None

This specifies if the memory usage of a DataFrame should be displayed when df.info() is called. Valid values True,False,’deep’ [default: True] [currently: True]  display.min_rows:int

The numbers of rows to show in a truncated view (when max_rows is exceeded). Ignored when max_rows is set to None or 0. When set to None, follows the value of max_rows. [default: 10] [currently: 10]  display.multi_sparse:boolean

“sparsify” MultiIndex display (don’t display repeated elements in outer levels within groups) [default: True] [currently: True]  display.notebook_repr_html:boolean

When True, IPython notebook will use html representation for pandas objects (if it is available). [default: True] [currently: True]  display.pprint_nest_depth:int

Controls the number of nested levels to process when pretty-printing [default: 3] [currently: 3]  display.precision:int

Floating point output precision in terms of number of places after the decimal, for regular formatting as well as scientific notation. Similar to precision in numpy.set_printoptions(). [default: 6] [currently: 6]  display.show_dimensions:boolean or ‘truncate’

Whether to print out dimensions at the end of DataFrame repr. If ‘truncate’ is specified, only print out the dimensions if the frame is truncated (e.g. not display all rows and/or columns) [default: truncate] [currently: truncate]  display.unicode.ambiguous_as_wide:boolean

Whether to use the Unicode East Asian Width to calculate the display text width. Enabling this may affect to the performance (default: False) [default: False] [currently: False]  display.unicode.east_asian_width:boolean

Whether to use the Unicode East Asian Width to calculate the display text width. Enabling this may affect to the performance (default: False) [default: False] [currently: False]  display.width:int

Width of the display in characters. In case python/IPython is running in a terminal this can be set to None and pandas will correctly auto-detect the width. Note that the IPython notebook, IPython qtconsole, or IDLE do not run in a terminal and hence it is not possible to correctly detect the width. [default: 80] [currently: 80]  io.excel.ods.reader:string

The default Excel reader engine for ‘ods’ files. Available options: auto, odf. [default: auto] [currently: auto]  io.excel.ods.writer:string

The default Excel writer engine for ‘ods’ files. Available options: auto, odf. [default: auto] [currently: auto]  io.excel.xls.reader:string

The default Excel reader engine for ‘xls’ files. Available options: auto, xlrd. [default: auto] [currently: auto]  io.excel.xls.writer:string

The default Excel writer engine for ‘xls’ files. Available options: auto, xlwt. [default: auto] [currently: auto] (Deprecated, use `` instead.)  io.excel.xlsb.reader:string

The default Excel reader engine for ‘xlsb’ files. Available options: auto, pyxlsb. [default: auto] [currently: auto]  io.excel.xlsm.reader:string

The default Excel reader engine for ‘xlsm’ files. Available options: auto, xlrd, openpyxl. [default: auto] [currently: auto]  io.excel.xlsm.writer:string

The default Excel writer engine for ‘xlsm’ files. Available options: auto, openpyxl. [default: auto] [currently: auto]  io.excel.xlsx.reader:string

The default Excel reader engine for ‘xlsx’ files. Available options: auto, xlrd, openpyxl. [default: auto] [currently: auto]  io.excel.xlsx.writer:string

The default Excel writer engine for ‘xlsx’ files. Available options: auto, openpyxl, xlsxwriter. [default: auto] [currently: auto]  io.hdf.default_format:format

default format writing format, if None, then put will default to ‘fixed’ and append will default to ‘table’ [default: None] [currently: None]  io.hdf.dropna_table:boolean

drop ALL nan rows when appending to a table [default: False] [currently: False]  io.parquet.engine:string

The default parquet reader/writer engine. Available options: ‘auto’, ‘pyarrow’, ‘fastparquet’, the default is ‘auto’ [default: auto] [currently: auto]  io.sql.engine:string

The default sql reader/writer engine. Available options: ‘auto’, ‘sqlalchemy’, the default is ‘auto’ [default: auto] [currently: auto]  mode.chained_assignment:string

Raise an exception, warn, or no action if trying to use chained assignment, The default is warn [default: warn] [currently: warn]  mode.data_manager:string

Internal data manager type; can be “block” or “array”. Defaults to “block”, unless overridden by the ‘PANDAS_DATA_MANAGER’ environment variable (needs to be set before pandas is imported). [default: block] [currently: block]  mode.sim_interactive:boolean

Whether to simulate interactive mode for purposes of testing [default: False] [currently: False]  mode.string_storage:string

The default storage for StringDtype. [default: python] [currently: python]  mode.use_inf_as_na:boolean

True means treat None, NaN, INF, -INF as NA (old way), False means None and NaN are null, but INF, -INF are not NA (new way). [default: False] [currently: False]  mode.use_inf_as_null:boolean

use_inf_as_null had been deprecated and will be removed in a future version. Use use_inf_as_na instead. [default: False] [currently: False] (Deprecated, use mode.use_inf_as_na instead.)  plotting.backend:str

The plotting backend to use. The default value is “matplotlib”, the backend provided with pandas. Other backends can be specified by providing the name of the module that implements the backend. [default: matplotlib] [currently: matplotlib]  plotting.matplotlib.register_converters:bool or ‘auto’.

Whether to register converters with matplotlib’s units registry for dates, times, datetimes, and Periods. Toggling to False will remove the converters, restoring any converters that pandas overwrote. [default: auto] [currently: auto]  styler.format.decimal:str

The character representation for the decimal separator for floats and complex. [default: .] [currently: .]  styler.format.escape:str, optional

Whether to escape certain characters according to the given context; html or latex. [default: None] [currently: None]  styler.format.formatter:str, callable, dict, optional

A formatter object to be used as default within Styler.format. [default: None] [currently: None]  styler.format.na_rep:str, optional

The string representation for values identified as missing. [default: None] [currently: None]  styler.format.precision:int

The precision for floats and complex numbers. [default: 6] [currently: 6]  styler.format.thousands:str, optional

The character representation for thousands separator for floats, int and complex. [default: None] [currently: None]  styler.html.mathjax:bool

If False will render special CSS classes to table attributes that indicate Mathjax will not be used in Jupyter Notebook. [default: True] [currently: True]  styler.latex.environment:str

The environment to replace \begin{table}. If “longtable” is used results in a specific longtable environment format. [default: None] [currently: None]  styler.latex.hrules:bool

Whether to add horizontal rules on top and bottom and below the headers. [default: False] [currently: False]  styler.latex.multicol_align:{“r”, “c”, “l”, “naive-l”, “naive-r”}

The specifier for horizontal alignment of sparsified LaTeX multicolumns. Pipe decorators can also be added to non-naive values to draw vertical rules, e.g. “|r” will draw a rule on the left side of right aligned merged cells. [default: r] [currently: r]  styler.latex.multirow_align:{“c”, “t”, “b”}

The specifier for vertical alignment of sparsified LaTeX multirows. [default: c] [currently: c]  styler.render.encoding:str

The encoding used for output HTML and LaTeX files. [default: utf-8] [currently: utf-8]  styler.render.max_columns:int, optional

The maximum number of columns that will be rendered. May still be reduced to satsify max_elements, which takes precedence. [default: None] [currently: None]  styler.render.max_elements:int

The maximum number of data-cell (<td>) elements that will be rendered before trimming will occur over columns, rows or both if needed. [default: 262144] [currently: 262144]  styler.render.max_rows:int, optional

The maximum number of rows that will be rendered. May still be reduced to satsify max_elements, which takes precedence. [default: None] [currently: None]  styler.render.repr:str

Determine which output to use in Jupyter Notebook in {“html”, “latex”}. [default: html] [currently: html]  styler.sparse.columns:bool

Whether to sparsify the display of hierarchical columns. Setting to False will display each explicit level element in a hierarchical key for each column. [default: True] [currently: True]  styler.sparse.index:bool

Whether to sparsify the display of a hierarchical index. Setting to False will display each explicit level element in a hierarchical key for each row. [default: True] [currently: True]


pandas.errors.AbstractMethodError   exceptionpandas.errors.AbstractMethodError(class_instance, methodtype='method')[source]

Raise this error instead of NotImplementedError for abstract methods while keeping compatibility with Python 2 and Python 3.


pandas.errors.AccessorRegistrationWarning   exceptionpandas.errors.AccessorRegistrationWarning[source]

Warning for attribute conflicts in accessor registration.


pandas.errors.DtypeWarning   exceptionpandas.errors.DtypeWarning[source]

Warning raised when reading different dtypes in a column from a file. Raised for a dtype incompatibility. This can happen whenever read_csv or read_table encounter non-uniform dtypes in a column(s) of a given CSV file.  See also  read_csv

Read CSV (comma-separated) file into a DataFrame.  read_table

Read general delimited file into a DataFrame.    Notes This warning is issued when dealing with larger files because the dtype checking happens per chunk read. Despite the warning, the CSV file is read with mixed types in a single column which will be an object type. See the examples below to better understand this issue. Examples This example creates and reads a large CSV file with a column that contains int and str.
>>> df = pd.DataFrame({'a': (['1'] * 100000 + ['X'] * 100000 +
...                          ['1'] * 100000),
...                    'b': ['b'] * 300000})
>>> df.to_csv('test.csv', index=False)
>>> df2 = pd.read_csv('test.csv')
... # DtypeWarning: Columns (0) have mixed types
  Important to notice that df2 will contain both str and int for the same input, ‘1’.
>>> df2.iloc[262140, 0]
'1'
>>> type(df2.iloc[262140, 0])
<class 'str'>
>>> df2.iloc[262150, 0]
1
>>> type(df2.iloc[262150, 0])
<class 'int'>
  One way to solve this issue is using the dtype parameter in the read_csv and read_table functions to explicit the conversion:
>>> df2 = pd.read_csv('test.csv', sep=',', dtype={'a': str})
  No warning was issued.


pandas.errors.DuplicateLabelError   exceptionpandas.errors.DuplicateLabelError[source]

Error raised when an operation would introduce duplicate labels.  New in version 1.2.0.  Examples
>>> s = pd.Series([0, 1, 2], index=['a', 'b', 'c']).set_flags(
...     allows_duplicate_labels=False
... )
>>> s.reindex(['a', 'a', 'b'])
Traceback (most recent call last):
   ...
DuplicateLabelError: Index has duplicates.
      positions
label
a        [0, 1]


pandas.errors.EmptyDataError   exceptionpandas.errors.EmptyDataError[source]

Exception that is thrown in pd.read_csv (by both the C and Python engines) when empty data or header is encountered.


pandas.errors.IntCastingNaNError   exceptionpandas.errors.IntCastingNaNError[source]

Raised when attempting an astype operation on an array with NaN to an integer dtype.


pandas.errors.InvalidIndexError   exceptionpandas.errors.InvalidIndexError[source]

Exception raised when attempting to use an invalid index key.  New in version 1.1.0.


pandas.errors.MergeError   exceptionpandas.errors.MergeError[source]

Error raised when problems arise during merging due to problems with input data. Subclass of ValueError.


pandas.errors.NullFrequencyError   exceptionpandas.errors.NullFrequencyError[source]

Error raised when a null freq attribute is used in an operation that needs a non-null frequency, particularly DatetimeIndex.shift, TimedeltaIndex.shift, PeriodIndex.shift.


pandas.errors.NumbaUtilError   exceptionpandas.errors.NumbaUtilError[source]

Error raised for unsupported Numba engine routines.


pandas.errors.OptionError   exceptionpandas.errors.OptionError[source]

Exception for pandas.options, backwards compatible with KeyError checks.


pandas.errors.OutOfBoundsDatetime   exceptionpandas.errors.OutOfBoundsDatetime


pandas.errors.OutOfBoundsTimedelta   exceptionpandas.errors.OutOfBoundsTimedelta

Raised when encountering a timedelta value that cannot be represented as a timedelta64[ns].


pandas.errors.ParserError   exceptionpandas.errors.ParserError[source]

Exception that is raised by an error encountered in parsing file contents. This is a generic error raised for errors encountered when functions like read_csv or read_html are parsing contents of a file.  See also  read_csv

Read CSV (comma-separated) file into a DataFrame.  read_html

Read HTML table into a DataFrame.


pandas.errors.ParserWarning   exceptionpandas.errors.ParserWarning[source]

Warning raised when reading a file that doesn’t use the default ‘c’ parser. Raised by pd.read_csv and pd.read_table when it is necessary to change parsers, generally from the default ‘c’ parser to ‘python’. It happens due to a lack of support or functionality for parsing a particular attribute of a CSV file with the requested engine. Currently, ‘c’ unsupported options include the following parameters:  sep other than a single character (e.g. regex separators) skipfooter higher than 0 sep=None with delim_whitespace=False  The warning can be avoided by adding engine=’python’ as a parameter in pd.read_csv and pd.read_table methods.  See also  pd.read_csv

Read CSV (comma-separated) file into DataFrame.  pd.read_table

Read general delimited file into DataFrame.    Examples Using a sep in pd.read_csv other than a single character:
>>> import io
>>> csv = '''a;b;c
...           1;1,8
...           1;2,1'''
>>> df = pd.read_csv(io.StringIO(csv), sep='[;,]')
... # ParserWarning: Falling back to the 'python' engine...
  Adding engine=’python’ to pd.read_csv removes the Warning:
>>> df = pd.read_csv(io.StringIO(csv), sep='[;,]', engine='python')


pandas.errors.PerformanceWarning   exceptionpandas.errors.PerformanceWarning[source]

Warning raised when there is a possible performance impact.


pandas.errors.UnsortedIndexError   exceptionpandas.errors.UnsortedIndexError[source]

Error raised when attempting to get a slice of a MultiIndex, and the index has not been lexsorted. Subclass of KeyError.


pandas.errors.UnsupportedFunctionCall   exceptionpandas.errors.UnsupportedFunctionCall[source]

Exception raised when attempting to call a numpy function on a pandas object, but that function is not supported by the object e.g. np.cumsum(groupby_object).