Return index of first occurrence of minimum over requested axis.
NA/null values are excluded.
The axis to use. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise.
Exclude NA/null values. If an entire row/column is NA, the result will be NA.
Indexes of minima along the specified axis.
If the row/column is empty
See also
Return index of the minimum element.
Notes
This method is the DataFrame version of ndarray.argmin.
Examples
Consider a dataset containing food consumption in Argentina.
By default, it returns the index for the minimum value in each column.
To return the index for the minimum value in each row, use axis="columns".


Return the mean absolute deviation of the values over the requested axis.
Axis for the function to be applied on.
Exclude NA/null values when computing the result.
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series.


Return DataFrame with counts of unique elements in each position.
Don’t include NaN in the counts.
Examples
Check for rows with the same id but conflicting values:


Forward fill the values.
Limit of how many values to fill.
Object with missing values filled.
See also
Returns Series with minimum number of char in object.
Object with missing values filled or None if inplace=True.
Fill NaN values of a Series.
Fill NaN values of a DataFrame.


Calculate pct_change of each value to previous entry in group.
Percentage changes within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Class implementing the .plot attribute for groupby objects.


Return group values at the given quantile, a la numpy.percentile.
Value(s) between 0 and 1 providing the quantile(s) to compute.
Method to use when the desired quantile falls between two points.
Return type determined by caller of GroupBy object.
See also
Similar method for Series.
Similar method for DataFrame.
NumPy method to compute qth percentile.
Examples


Provide the rank of values within each group.
average: average rank of group.
min: lowest rank in group.
max: highest rank in group.
first: ranks assigned in order they appear in the array.
dense: like ‘min’, but rank always increases by 1 between groups.
False for ranks by high (1) to low (N).
keep: leave NA values where they are.
top: smallest rank if ascending.
bottom: smallest rank if descending.
Compute percentage rank of data within each group.
The axis of the object over which to compute the rank.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.
Examples


Provide resampling when using a TimeGrouper.
Given a grouper, the function resamples it according to a string “string” -> “frequency”.
See the frequency aliases documentation for more details.
The offset string or object representing target grouper conversion.
Possible arguments are how, fill_method, limit, kind and on, and other arguments of TimeGrouper.
Return a new grouper with our resampler appended.
See also
Specify a frequency to resample with when grouping by a key.
Frequency conversion and resampling of time series.
Examples
Downsample the DataFrame into 3 minute bins and sum the values of the timestamps falling into a bin.
Upsample the series into 30 second bins.
Resample by month. Values are assigned to the month of the period.
Downsample the series into 3 minute bins as above, but close the right side of the bin interval.
Downsample the series into 3 minute bins and close the right side of the bin interval, but label each bin using the right edge instead of the left.


Return a random sample of items from each group.
You can use random_state for reproducibility.
New in version 1.1.0.
Number of items to return for each group. Cannot be used with frac and must be no larger than the smallest group unless replace is True. Default is one if frac is None.
Fraction of items to return. Cannot be used with n.
Allow or disallow sampling of the same row more than once.
Default None results in equal probability weighting. If passed a list-like then values must have the same length as the underlying DataFrame or Series object and will be used as sampling probabilities after normalization within each group. Values must be non-negative with at least one positive element within each group.
If int, array-like, or BitGenerator, seed for random number generator. If np.random.RandomState or np.random.Generator, use as given.
Changed in version 1.4.0: np.random.Generator objects now accepted
A new object of same type as caller containing items randomly sampled within each group from the caller object.
See also
Generate random samples from a DataFrame object.
Generate a random sample from a given 1-D numpy array.
Examples
Select one row at random for each distinct value in column a. The random_state argument can be used to guarantee reproducibility:
Set frac to sample fixed proportions rather than counts:
Control sample probabilities within groups by setting weights:


Shift each group by periods observations.
If freq is passed, the index will be increased using the periods and the freq.
Number of periods to shift.
Frequency string.
Shift direction.
The scalar value to use for newly introduced missing values.
Object shifted within each group.
See also
Shift values of Index.
Shift the time index, using the index’s frequency if available.


Compute group sizes.
Number of rows in each group as a Series if as_index is True or a DataFrame if as_index is False.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Return unbiased skew over requested axis.
Normalized by N-1.
Axis for the function to be applied on.
Exclude NA/null values when computing the result.
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.
Additional keyword arguments to be passed to the function.


Return the elements in the given positional indices along an axis.
This means that we are not indexing according to actual values in the index attribute of the object. We are indexing according to the actual position of the element in the object.
An array of ints indicating which positions to take.
The axis on which to select elements. 0 means that we are selecting rows, 1 means that we are selecting columns.
Before pandas 1.0, is_copy=False can be specified to ensure that the return value is an actual copy. Starting with pandas 1.0, take always returns a copy, and the keyword is therefore deprecated.
Deprecated since version 1.0.0.
For compatibility with numpy.take(). Has no effect on the output.
An array-like containing the elements taken from the object.
See also
Select a subset of a DataFrame by labels.
Select a subset of a DataFrame by positions.
Take elements from an array along an axis.
Examples
Take elements at positions 0 and 3 along the axis 0 (default).
Note how the actual indices selected (0 and 1) do not correspond to our selected indices 0 and 3. That’s because we are selecting the 0th and 3rd rows, not rows whose indices equal 0 and 3.
Take elements at indices 1 and 2 along the axis 1 (column selection).
We may take elements using negative integers for positive indices, starting from the end of the object, just like with Python lists.


Call function producing a like-indexed DataFrame on each group and return a DataFrame having the same indexes as the original object filled with the transformed values.
Function to apply to each group.
Can also accept a Numba JIT function with engine='numba' specified.
If the 'numba' engine is chosen, the function must be a user defined function with values and index as the first and second arguments respectively in the function signature. Each group’s index will be passed to the user defined function and optionally available for use.
Changed in version 1.1.0.
Positional arguments to pass to func.
'cython' : Runs the function through C-extensions from cython.
'numba' : Runs the function through JIT compiled code from numba.
None : Defaults to 'cython' or the global setting compute.use_numba
New in version 1.1.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False} and will be applied to the function
New in version 1.1.0.
Keyword arguments to be passed into func.
See also
Apply function func group-wise and combine the results together.
Aggregate using one or more operations over the specified axis.
Call func on self producing a DataFrame with the same axis shape as self.
Notes
Each group is endowed the attribute ‘name’ in case you need to know which group you are working on.
The current implementation imposes three requirements on f:
f must return a value that either has the same shape as the input subframe or can be broadcast to the shape of the input subframe. For example, if f returns a scalar it will be broadcast to have the same shape as the input subframe.
if this is a DataFrame, f must support application column-by-column in the subframe. If f also supports application to the entire subframe, then a fast path is used starting from the second chunk.
f must not mutate groups. Mutation is not supported and may produce unexpected results. See Mutating with User Defined Function (UDF) methods for more details.
When using engine='numba', there will be no “fall back” behavior internally. The group data and group index will be passed as numpy arrays to the JITed user defined function, and no alternative execution attempts will be tried.
Changed in version 1.3.0: The resulting dtype will reflect the return value of the passed func, see the examples below.
Examples
Broadcast result of the transformation
Changed in version 1.3.0: The resulting dtype will reflect the return value of the passed func, for example:


Shift the time index, using the index’s frequency if available.
Deprecated since version 1.1.0: Use shift instead.
Number of periods to move, can be positive or negative.
Increment to use from the tseries module or time rule expressed as a string (e.g. ‘EOM’).
Corresponds to the axis that contains the Index.
Notes
If freq is not specified then tries to use the freq or inferred_freq attributes of the index. If neither of those attributes exist, a ValueError is thrown


Return a Series or DataFrame containing counts of unique rows.
New in version 1.4.0.
Columns to use when counting unique combinations.
Return proportions rather than frequencies.
Sort by frequencies.
Sort in ascending order.
Don’t include counts of rows that contain NA values.
Series if the groupby as_index is True, otherwise DataFrame.
See also
Equivalent method on Series.
Equivalent method on DataFrame.
Equivalent method on SeriesGroupBy.
Notes
If the groupby as_index is True then the returned Series will have a MultiIndex with one level per input column.
If the groupby as_index is False then the returned DataFrame will have an additional column with the value_counts. The column is labelled ‘count’ or ‘proportion’, depending on the normalize parameter.
By default, rows that contain any NA values are omitted from the result.
By default, the result will be in descending order so that the first element of each group is the most frequently-occurring row.
Examples


Return True if all values in the group are truthful, else False.
Flag to ignore nan values during truth testing.
DataFrame or Series of boolean values, where a value is True if all elements are True within its respective group, False otherwise.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Return True if any value in the group is truthful, else False.
Flag to ignore nan values during truth testing.
DataFrame or Series of boolean values, where a value is True if any element is True within its respective group, False otherwise.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Apply function func group-wise and combine the results together.
The function passed to apply must take a dataframe as its first argument and return a DataFrame, Series or scalar. apply will then take care of combining the results back together into a single dataframe or series. apply is therefore a highly flexible grouping method.
While apply is a very flexible method, its downside is that using it can be quite a bit slower than using more specific methods like agg or transform. Pandas offers a wide range of method that will be much faster than using apply for their specific purposes, so try to use them before reaching for apply.
A callable that takes a dataframe as its first argument, and returns a dataframe, a series or a scalar. In addition the callable may take positional and keyword arguments.
Optional positional and keyword arguments to pass to func.
See also
Apply function to the full GroupBy object instead of to each group.
Apply aggregate function to the GroupBy object.
Apply function column-by-column to the GroupBy object.
Apply a function to a Series.
Apply a function to each row or column of a DataFrame.
Notes
Changed in version 1.3.0: The resulting dtype will reflect the return value of the passed func, see the examples below.
Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details.
Examples
Notice that g has two groups, a and b. Calling apply in various ways, we can get different grouping results:
Example 1: below the function passed to apply takes a DataFrame as its argument and returns a DataFrame. apply combines the result for each group together into a new DataFrame:
Example 2: The function passed to apply takes a DataFrame as its argument and returns a Series. apply combines the result for each group together into a new DataFrame.
Changed in version 1.3.0: The resulting dtype will reflect the return value of the passed func.
Example 3: The function passed to apply takes a DataFrame as its argument and returns a scalar. apply combines the result for each group together into a Series, including setting the index as appropriate:


Backward fill the values.
Limit of how many values to fill.
Object with missing values filled.
See also
Backward fill the missing values in the dataset.
Backward fill the missing values in the dataset.
Fill NaN values of a Series.
Fill NaN values of a DataFrame.


Compute count of group, excluding missing values.
Count of values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Number each item in each group from 0 to the length of that group - 1.
Essentially this is equivalent to
If False, number in reverse, from length of group - 1 to 0.
Sequence number of each element within each group.
See also
Number the groups themselves.
Examples


Cumulative max for each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Cumulative min for each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Cumulative product for each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Cumulative sum for each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Forward fill the values.
Limit of how many values to fill.
Object with missing values filled.
See also
Returns Series with minimum number of char in object.
Object with missing values filled or None if inplace=True.
Fill NaN values of a Series.
Fill NaN values of a DataFrame.


Compute first of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed first of values within each group.


Construct DataFrame from group with provided name.
The name of the group to get as a DataFrame.
The DataFrame to take the DataFrame out of. If it is None, the object groupby was called on will be used.


Return first n rows of each group.
Similar to .apply(lambda x: x.head(n)), but it returns a subset of rows from the original DataFrame with original index and order preserved (as_index flag is ignored).
If positive: number of entries to include from start of each group. If negative: number of entries to exclude from end of each group.
Subset of original Series or DataFrame as determined by n.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.
Examples


Compute last of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed last of values within each group.


Compute max of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed max of values within each group.


Compute mean of groups, excluding missing values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.4.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {{'nopython': True, 'nogil': False, 'parallel': False}}
New in version 1.4.0.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.
Examples
Groupby one column and return the mean of the remaining columns in each group.
Groupby two columns and return the mean of the remaining column.
Groupby one column and return the mean of only particular column in the group.


Compute median of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
Median of values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Compute min of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed min of values within each group.


Number each group from 0 to the number of groups - 1.
This is the enumerative complement of cumcount. Note that the numbers given to the groups match the order in which the groups would be seen when iterating over the groupby object, not the order they are first observed.
If False, number in reverse, from number of group - 1 to 0.
Unique numbers for each group.
See also
Number the rows in each group.
Examples


Take the nth row from each group if n is an int, otherwise a subset of rows.
Can be either a call or an index. dropna is not available with index notation. Index notation accepts a comma separated list of integers and slices.
If dropna, will take the nth non-null row, dropna is either ‘all’ or ‘any’; this is equivalent to calling dropna(how=dropna) before the groupby.
A single nth value for the row or a list of nth values or slices.
Changed in version 1.4.0: Added slice and lists containiing slices. Added index notation.
Apply the specified dropna operation before counting which row is the nth row. Only supported if n is an int.
N-th value within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.
Examples
Index notation may also be used
Specifying dropna allows count ignoring NaN
NaNs denote group exhausted when using dropna
Specifying as_index=False in groupby keeps the original index.


Compute open, high, low and close values of a group, excluding missing values.
For multiple groupings, the result index will be a MultiIndex
Open, high, low and close values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Calculate pct_change of each value to previous entry in group.
Percentage changes within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Apply a function func with arguments to this GroupBy object and return the function’s result.
Use .pipe when you want to improve readability by chaining together functions that expect Series, DataFrames, GroupBy or Resampler objects. Instead of writing
You can write
which is much more readable.
Function to apply to this GroupBy object or, alternatively, a (callable, data_keyword) tuple where data_keyword is a string indicating the keyword of callable that expects the GroupBy object.
Positional arguments passed into func.
A dictionary of keyword arguments passed into func.
See also
Apply a function with arguments to a series.
Apply a function with arguments to a dataframe.
Apply function to each group instead of to the full GroupBy object.
Notes
See more here
Examples
To get the difference between each groups maximum and minimum value in one pass, you can do


Compute prod of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed prod of values within each group.


Provide the rank of values within each group.
average: average rank of group.
min: lowest rank in group.
max: highest rank in group.
first: ranks assigned in order they appear in the array.
dense: like ‘min’, but rank always increases by 1 between groups.
False for ranks by high (1) to low (N).
keep: leave NA values where they are.
top: smallest rank if ascending.
bottom: smallest rank if descending.
Compute percentage rank of data within each group.
The axis of the object over which to compute the rank.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.
Examples


Compute standard error of the mean of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
Degrees of freedom.
Standard error of the mean of values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Compute group sizes.
Number of rows in each group as a Series if as_index is True or a DataFrame if as_index is False.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Compute standard deviation of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
Degrees of freedom.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.4.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {{'nopython': True, 'nogil': False, 'parallel': False}}
New in version 1.4.0.
Standard deviation of values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Compute sum of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed sum of values within each group.


Return last n rows of each group.
Similar to .apply(lambda x: x.tail(n)), but it returns a subset of rows from the original DataFrame with original index and order preserved (as_index flag is ignored).
If positive: number of entries to include from end of each group. If negative: number of entries to exclude from start of each group.
Subset of original Series or DataFrame as determined by n.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.
Examples


Compute variance of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
Degrees of freedom.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.4.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {{'nopython': True, 'nogil': False, 'parallel': False}}
New in version 1.4.0.
Variance of values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Aggregate using one or more operations over the specified axis.
Function to use for aggregating the data. If a function, must either work when passed a Series or when passed to Series.apply.
Accepted combinations are:
function
string function name
list of functions and/or function names, e.g. [np.sum, 'mean']
dict of axis labels -> functions, function names or list of such.
Can also accept a Numba JIT function with engine='numba' specified. Only passing a single function is supported with this engine.
If the 'numba' engine is chosen, the function must be a user defined function with values and index as the first and second arguments respectively in the function signature. Each group’s index will be passed to the user defined function and optionally available for use.
Changed in version 1.1.0.
Positional arguments to pass to func.
'cython' : Runs the function through C-extensions from cython.
'numba' : Runs the function through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.1.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False} and will be applied to the function
New in version 1.1.0.
Keyword arguments to be passed into func.
See also
Apply function func group-wise and combine the results together.
Aggregate using one or more operations over the specified axis.
Transforms the Series on each group based on the given function.
Notes
When using engine='numba', there will be no “fall back” behavior internally. The group data and group index will be passed as numpy arrays to the JITed user defined function, and no alternative execution attempts will be tried.
Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details.
Changed in version 1.3.0: The resulting dtype will reflect the return value of the passed func, see the examples below.
Examples
The output column names can be controlled by passing the desired column names and aggregations as keyword arguments.
Changed in version 1.3.0: The resulting dtype will reflect the return value of the aggregating function.


Draw histogram of the input series using matplotlib.
If passed, then used to form histograms for separate groups.
If not passed, uses gca().
Whether to show axis grid lines.
If specified changes the x-axis label size.
Rotation of x axis labels.
If specified changes the y-axis label size.
Rotation of y axis labels.
Figure size in inches by default.
Number of histogram bins to be used. If an integer is given, bins + 1 bin edges are calculated and returned. If bins is a sequence, gives bin edges, including left edge of first bin and right edge of last bin. In this case, bins is returned unmodified.
Backend to use instead of the backend specified in the option plotting.backend. For instance, ‘matplotlib’. Alternatively, to specify the plotting.backend for the whole session, set pd.options.plotting.backend.
New in version 1.0.0.
Whether to show the legend.
New in version 1.1.0.
To be passed to the actual plotting function.
A histogram plot.
See also
Plot a histogram using matplotlib.


Return boolean if values in the object are monotonic_decreasing.


Return the largest n elements.
Return this many descending sorted values.
When there are duplicate values that cannot all fit in a Series of n elements:
first : return the first n occurrences in order of appearance.
last : return the last n occurrences in reverse order of appearance.
all : keep all occurrences. This can result in a Series of size larger than n.
The n largest values in the Series, sorted in decreasing order.
See also
Get the n smallest elements.
Sort Series by values.
Return the first n rows.
Notes
Faster than .sort_values(ascending=False).head(n) for small n relative to the size of the Series object.
Examples
The n largest elements where n=5 by default.
The n largest elements where n=3. Default keep value is ‘first’ so Malta will be kept.
The n largest elements where n=3 and keeping the last duplicates. Brunei will be kept since it is the last with value 434000 based on the index order.
The n largest elements where n=3 with all duplicates kept. Note that the returned Series has five elements due to the three duplicates.


Return the smallest n elements.
Return this many ascending sorted values.
When there are duplicate values that cannot all fit in a Series of n elements:
first : return the first n occurrences in order of appearance.
last : return the last n occurrences in reverse order of appearance.
all : keep all occurrences. This can result in a Series of size larger than n.
The n smallest values in the Series, sorted in increasing order.
See also
Get the n largest elements.
Sort Series by values.
Return the first n rows.
Notes
Faster than .sort_values().head(n) for small n relative to the size of the Series object.
Examples
The n smallest elements where n=5 by default.
The n smallest elements where n=3. Default keep value is ‘first’ so Nauru and Tuvalu will be kept.
The n smallest elements where n=3 and keeping the last duplicates. Anguilla and Tuvalu will be kept since they are the last with value 11300 based on the index order.
The n smallest elements where n=3 with all duplicates kept. Note that the returned Series has four elements due to the three duplicates.


Return number of unique elements in the group.
Number of unique values within each group.


Call function producing a like-indexed Series on each group and return a Series having the same indexes as the original object filled with the transformed values.
Function to apply to each group.
Can also accept a Numba JIT function with engine='numba' specified.
If the 'numba' engine is chosen, the function must be a user defined function with values and index as the first and second arguments respectively in the function signature. Each group’s index will be passed to the user defined function and optionally available for use.
Changed in version 1.1.0.
Positional arguments to pass to func.
'cython' : Runs the function through C-extensions from cython.
'numba' : Runs the function through JIT compiled code from numba.
None : Defaults to 'cython' or the global setting compute.use_numba
New in version 1.1.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False} and will be applied to the function
New in version 1.1.0.
Keyword arguments to be passed into func.
See also
Apply function func group-wise and combine the results together.
Aggregate using one or more operations over the specified axis.
Call func on self producing a Series with the same axis shape as self.
Notes
Each group is endowed the attribute ‘name’ in case you need to know which group you are working on.
The current implementation imposes three requirements on f:
f must return a value that either has the same shape as the input subframe or can be broadcast to the shape of the input subframe. For example, if f returns a scalar it will be broadcast to have the same shape as the input subframe.
if this is a DataFrame, f must support application column-by-column in the subframe. If f also supports application to the entire subframe, then a fast path is used starting from the second chunk.
f must not mutate groups. Mutation is not supported and may produce unexpected results. See Mutating with User Defined Function (UDF) methods for more details.
When using engine='numba', there will be no “fall back” behavior internally. The group data and group index will be passed as numpy arrays to the JITed user defined function, and no alternative execution attempts will be tried.
Changed in version 1.3.0: The resulting dtype will reflect the return value of the passed func, see the examples below.
Examples
Broadcast result of the transformation
Changed in version 1.3.0: The resulting dtype will reflect the return value of the passed func, for example:


Return unique values of Series object.
Uniques are returned in order of appearance. Hash table-based unique, therefore does NOT sort.
The unique values returned as a NumPy array. See Notes.
See also
Top-level unique method for any 1-d array-like object.
Return Index with unique values from an Index object.
Notes
Returns the unique values as a NumPy array. In case of an extension-array backed Series, a new ExtensionArray of that type with just the unique values is returned. This includes
Categorical
Period
Datetime with Timezone
Interval
Sparse
IntegerNA
See Examples section.
Examples
An Categorical will return categories in the order of appearance and with the same dtype.


Aggregate using one or more operations over the specified axis.
Function to use for aggregating the data. If a function, must either work when passed a DataFrame or when passed to DataFrame.apply.
Accepted combinations are:
function
string function name
list of functions and/or function names, e.g. [np.sum, 'mean']
dict of axis labels -> functions, function names or list of such.
Positional arguments to pass to func.
Keyword arguments to pass to func.
The return can be:
scalar : when Series.agg is called with single function
Series : when DataFrame.agg is called with a single function
DataFrame : when DataFrame.agg is called with several functions
Return scalar, Series or DataFrame.
See also
Aggregate using callable, string, dict, or list of string/callables.
Transforms the Series on each group based on the given function.
Aggregate using one or more operations over the specified axis.
Notes
agg is an alias for aggregate. Use the alias.
Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details.
A passed user-defined-function will be passed a Series for evaluation.
Examples


Return the values at the new freq, essentially a reindex.
Value to use for missing values, applied during upsampling (note this does not fill NaNs that already were present).
Values at the specified freq.
See also
Convert TimeSeries to specified frequency.
Convert TimeSeries to specified frequency.


Backward fill the new missing values in the resampled data.
In statistics, imputation is the process of replacing missing data with substituted values [1]. When resampling data, missing values may appear (e.g., when the resampling frequency is higher than the original frequency). The backward fill will replace NaN values that appeared in the resampled data with the next value in the original sequence. Missing values that existed in the original data will not be modified.
Limit of how many values to fill.
An upsampled Series or DataFrame with backward filled NaN values.
See also
Alias of backfill.
Fill NaN values using the specified method, which can be ‘backfill’.
Fill NaN values with nearest neighbor starting from center.
Forward fill NaN values.
Fill NaN values in the Series using the specified method, which can be ‘backfill’.
Fill NaN values in the DataFrame using the specified method, which can be ‘backfill’.
References
https://en.wikipedia.org/wiki/Imputation_(statistics)
Examples
Resampling a Series:
Resampling a DataFrame that has missing values:


Compute count of group, excluding missing values.
Count of values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Forward fill the values.
Limit of how many values to fill.
See also
Fill NA/NaN values using the specified method.
Fill NA/NaN values using the specified method.


Fill missing values introduced by upsampling.
In statistics, imputation is the process of replacing missing data with substituted values [1]. When resampling data, missing values may appear (e.g., when the resampling frequency is higher than the original frequency).
Missing values that existed in the original data will not be modified.
Method to use for filling holes in resampled data
‘pad’ or ‘ffill’: use previous valid observation to fill gap (forward fill).
‘backfill’ or ‘bfill’: use next valid observation to fill gap.
‘nearest’: use nearest valid observation to fill gap.
Limit of how many consecutive missing values to fill.
An upsampled Series or DataFrame with missing values filled.
See also
Backward fill NaN values in the resampled data.
Forward fill NaN values in the resampled data.
Fill NaN values in the resampled data with nearest neighbor starting from center.
Fill NaN values using interpolation.
Fill NaN values in the Series using the specified method, which can be ‘bfill’ and ‘ffill’.
Fill NaN values in the DataFrame using the specified method, which can be ‘bfill’ and ‘ffill’.
References
https://en.wikipedia.org/wiki/Imputation_(statistics)
Examples
Resampling a Series:
Without filling the missing values you get:
Missing values present before the upsampling are not affected.
DataFrame resampling is done column-wise. All the same options are available.


Compute first of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed first of values within each group.


Construct DataFrame from group with provided name.
The name of the group to get as a DataFrame.
The DataFrame to take the DataFrame out of. If it is None, the object groupby was called on will be used.


Interpolate values according to different methods.
Fill NaN values using an interpolation method.
Please note that only method='linear' is supported for DataFrame/Series with a MultiIndex.
Interpolation technique to use. One of:
‘linear’: Ignore the index and treat the values as equally spaced. This is the only method supported on MultiIndexes.
‘time’: Works on daily and higher resolution data to interpolate given length of interval.
‘index’, ‘values’: use the actual numerical values of the index.
‘pad’: Fill in NaNs using existing values.
‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘spline’, ‘barycentric’, ‘polynomial’: Passed to scipy.interpolate.interp1d. These methods use the numerical values of the index. Both ‘polynomial’ and ‘spline’ require that you also specify an order (int), e.g. df.interpolate(method='polynomial', order=5).
‘krogh’, ‘piecewise_polynomial’, ‘spline’, ‘pchip’, ‘akima’, ‘cubicspline’: Wrappers around the SciPy interpolation methods of similar names. See Notes.
‘from_derivatives’: Refers to scipy.interpolate.BPoly.from_derivatives which replaces ‘piecewise_polynomial’ interpolation method in scipy 0.18.
Axis to interpolate along.
Maximum number of consecutive NaNs to fill. Must be greater than 0.
Update the data in place if possible.
Consecutive NaNs will be filled in this direction.
If ‘method’ is ‘pad’ or ‘ffill’, ‘limit_direction’ must be ‘forward’.
If ‘method’ is ‘backfill’ or ‘bfill’, ‘limit_direction’ must be ‘backwards’.
If ‘method’ is ‘backfill’ or ‘bfill’, the default is ‘backward’
else the default is ‘forward’
Changed in version 1.1.0: raises ValueError if limit_direction is ‘forward’ or ‘both’ and method is ‘backfill’ or ‘bfill’. raises ValueError if limit_direction is ‘backward’ or ‘both’ and method is ‘pad’ or ‘ffill’.
If limit is specified, consecutive NaNs will be filled with this restriction.
None: No fill restriction.
‘inside’: Only fill NaNs surrounded by valid values (interpolate).
‘outside’: Only fill NaNs outside valid values (extrapolate).
Downcast dtypes if possible.
Keyword arguments to pass on to the interpolating function.
Returns the same object type as the caller, interpolated at some or all NaN values or None if inplace=True.
See also
Fill missing values using different methods.
Piecewise cubic polynomials (Akima interpolator).
Piecewise polynomial in the Bernstein basis.
Interpolate a 1-D function.
Interpolate polynomial (Krogh interpolator).
PCHIP 1-d monotonic cubic interpolation.
Cubic spline data interpolator.
Notes
The ‘krogh’, ‘piecewise_polynomial’, ‘spline’, ‘pchip’ and ‘akima’ methods are wrappers around the respective SciPy implementations of similar names. These use the actual numerical values of the index. For more information on their behavior, see the SciPy documentation and SciPy tutorial.
Examples
Filling in NaN in a Series via linear interpolation.
Filling in NaN in a Series by padding, but filling at most two consecutive NaN at a time.
Filling in NaN in a Series via polynomial interpolation or splines: Both ‘polynomial’ and ‘spline’ methods require that you also specify an order (int).
Fill the DataFrame forward (that is, going down) along each column using linear interpolation.
Note how the last entry in column ‘a’ is interpolated differently, because there is no entry after it to use for interpolation. Note how the first entry in column ‘b’ remains NaN, because there is no entry before it to use for interpolation.
Using polynomial interpolation.


Compute last of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed last of values within each group.


Compute max of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed max of values within each group.


Compute mean of groups, excluding missing values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.4.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {{'nopython': True, 'nogil': False, 'parallel': False}}
New in version 1.4.0.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.
Examples
Groupby one column and return the mean of the remaining columns in each group.
Groupby two columns and return the mean of the remaining column.
Groupby one column and return the mean of only particular column in the group.


Compute median of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
Median of values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Compute min of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed min of values within each group.


Resample by using the nearest value.
When resampling data, missing values may appear (e.g., when the resampling frequency is higher than the original frequency). The nearest method will replace NaN values that appeared in the resampled data with the value from the nearest member of the sequence, based on the index value. Missing values that existed in the original data will not be modified. If limit is given, fill only this many values in each direction for each of the original values.
Limit of how many values to fill.
An upsampled Series or DataFrame with NaN values filled with their nearest value.
See also
Backward fill the new missing values in the resampled data.
Forward fill NaN values.
Examples
Limit the number of upsampled values imputed by the nearest:


Return number of unique elements in the group.
Number of unique values within each group.


Compute open, high, low and close values of a group, excluding missing values.
For multiple groupings, the result index will be a MultiIndex
Open, high, low and close values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Apply a function func with arguments to this Resampler object and return the function’s result.
Use .pipe when you want to improve readability by chaining together functions that expect Series, DataFrames, GroupBy or Resampler objects. Instead of writing
You can write
which is much more readable.
Function to apply to this Resampler object or, alternatively, a (callable, data_keyword) tuple where data_keyword is a string indicating the keyword of callable that expects the Resampler object.
Positional arguments passed into func.
A dictionary of keyword arguments passed into func.
See also
Apply a function with arguments to a series.
Apply a function with arguments to a dataframe.
Apply function to each group instead of to the full Resampler object.
Notes
See more here
Examples
To get the difference between each 2-day period’s maximum and minimum value in one pass, you can do


Compute prod of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed prod of values within each group.


Return value at the given quantile.
Quantile of values within each group.
See also
Return a series, where the index is q and the values are the quantiles.
Return a DataFrame, where the columns are the columns of self, and the values are the quantiles.
Return a DataFrame, where the coulmns are groupby columns, and the values are its quantiles.


Compute standard error of the mean of groups, excluding missing values.
For multiple groupings, the result index will be a MultiIndex.
Degrees of freedom.
Standard error of the mean of values within each group.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Compute group sizes.
Number of rows in each group as a Series if as_index is True or a DataFrame if as_index is False.
See also
Apply a function groupby to a Series.
Apply a function groupby to each row or column of a DataFrame.


Compute standard deviation of groups, excluding missing values.
Degrees of freedom.
Standard deviation of values within each group.


Compute sum of group values.
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data.
The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.
Computed sum of values within each group.


Call function producing a like-indexed Series on each group and return a Series with the transformed values.
To apply to each group. Should return a Series with the same index.
Examples


Compute variance of groups, excluding missing values.
Degrees of freedom.
Variance of values within each group.


Calculate the ewm (exponential weighted moment) sample correlation.
If not supplied then will default to self and produce pairwise output.
If False then only matching columns between self and other will be used and the output will be a DataFrame. If True then all pairwise combinations will be calculated and the output will be a MultiIndex DataFrame in the case of DataFrame inputs. In the case of missing elements, only complete pairwise observations will be used.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling ewm with Series data.
Calling ewm with DataFrames.
Aggregating corr for Series.
Aggregating corr for DataFrame.


Calculate the ewm (exponential weighted moment) sample covariance.
If not supplied then will default to self and produce pairwise output.
If False then only matching columns between self and other will be used and the output will be a DataFrame. If True then all pairwise combinations will be calculated and the output will be a MultiIndex DataFrame in the case of DataFrame inputs. In the case of missing elements, only complete pairwise observations will be used.
Use a standard estimation bias correction.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling ewm with Series data.
Calling ewm with DataFrames.
Aggregating cov for Series.
Aggregating cov for DataFrame.


Calculate the ewm (exponential weighted moment) mean.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling ewm with Series data.
Calling ewm with DataFrames.
Aggregating mean for Series.
Aggregating mean for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.


Calculate the ewm (exponential weighted moment) standard deviation.
Use a standard estimation bias correction.
For NumPy compatibility and will not have an effect on the result.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling ewm with Series data.
Calling ewm with DataFrames.
Aggregating std for Series.
Aggregating std for DataFrame.


Calculate the ewm (exponential weighted moment) sum.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling ewm with Series data.
Calling ewm with DataFrames.
Aggregating sum for Series.
Aggregating sum for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.


Calculate the ewm (exponential weighted moment) variance.
Use a standard estimation bias correction.
For NumPy compatibility and will not have an effect on the result.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling ewm with Series data.
Calling ewm with DataFrames.
Aggregating var for Series.
Aggregating var for DataFrame.


Aggregate using one or more operations over the specified axis.
Function to use for aggregating the data. If a function, must either work when passed a Series/Dataframe or when passed to Series/Dataframe.apply.
Accepted combinations are:
function
string function name
list of functions and/or function names, e.g. [np.sum, 'mean']
dict of axis labels -> functions, function names or list of such.
Positional arguments to pass to func.
Keyword arguments to pass to func.
The return can be:
scalar : when Series.agg is called with single function
Series : when DataFrame.agg is called with a single function
DataFrame : when DataFrame.agg is called with several functions
Return scalar, Series or DataFrame.
See also
Similar DataFrame method.
Similar Series method.
Notes
agg is an alias for aggregate. Use the alias.
Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details.
A passed user-defined-function will be passed a Series for evaluation.
Examples


Calculate the expanding custom aggregation function.
Must produce a single value from an ndarray input if raw=True or a single value from a Series if raw=False. Can also accept a Numba JIT function with engine='numba' specified.
Changed in version 1.0.0.
False : passes each row or column as a Series to the function.
True : the passed function will receive ndarray objects instead. If you are just applying a NumPy reduction function this will achieve much better performance.
'cython' : Runs rolling apply through C-extensions from cython.
'numba' : Runs rolling apply through JIT compiled code from numba. Only available when raw is set to True.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.0.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False} and will be applied to both the func and the apply rolling aggregation.
New in version 1.0.0.
Positional arguments to be passed into func.
Keyword arguments to be passed into func.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating apply for Series.
Aggregating apply for DataFrame.


Calculate the expanding correlation.
If not supplied then will default to self and produce pairwise output.
If False then only matching columns between self and other will be used and the output will be a DataFrame. If True then all pairwise combinations will be calculated and the output will be a MultiIndexed DataFrame in the case of DataFrame inputs. In the case of missing elements, only complete pairwise observations will be used.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Similar method to calculate covariance.
NumPy Pearson’s correlation calculation.
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating corr for Series.
Aggregating corr for DataFrame.
Notes
This function uses Pearson’s definition of correlation (https://en.wikipedia.org/wiki/Pearson_correlation_coefficient).
When other is not specified, the output will be self correlation (e.g. all 1’s), except for DataFrame inputs with pairwise set to True.
Function will return NaN for correlations of equal valued sequences; this is the result of a 0/0 division error.
When pairwise is set to False, only matching columns between self and other will be used.
When pairwise is set to True, the output will be a MultiIndex DataFrame with the original index on the first level, and the other DataFrame columns on the second level.
In the case of missing elements, only complete pairwise observations will be used.


Calculate the expanding count of non NaN observations.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating count for Series.
Aggregating count for DataFrame.


Calculate the expanding sample covariance.
If not supplied then will default to self and produce pairwise output.
If False then only matching columns between self and other will be used and the output will be a DataFrame. If True then all pairwise combinations will be calculated and the output will be a MultiIndexed DataFrame in the case of DataFrame inputs. In the case of missing elements, only complete pairwise observations will be used.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating cov for Series.
Aggregating cov for DataFrame.


Calculate the expanding Fisher’s definition of kurtosis without bias.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Reference SciPy method.
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating kurt for Series.
Aggregating kurt for DataFrame.
Notes
A minimum of four periods is required for the calculation.
Examples
The example below will show a rolling calculation with a window size of four matching the equivalent function call using scipy.stats.


Calculate the expanding maximum.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating max for Series.
Aggregating max for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.


Calculate the expanding mean.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating mean for Series.
Aggregating mean for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.


Calculate the expanding median.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating median for Series.
Aggregating median for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.


Calculate the expanding minimum.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating min for Series.
Aggregating min for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.


Calculate the expanding quantile.
Quantile to compute. 0 <= quantile <= 1.
This optional parameter specifies the interpolation method to use, when the desired quantile lies between two data points i and j:
linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.
lower: i.
higher: j.
nearest: i or j whichever is nearest.
midpoint: (i + j) / 2.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating quantile for Series.
Aggregating quantile for DataFrame.


Calculate the expanding rank.
New in version 1.4.0.
How to rank the group of records that have the same value (i.e. ties):
average: average rank of the group
min: lowest rank in the group
max: highest rank in the group
Whether or not the elements should be ranked in ascending order.
Whether or not to display the returned rankings in percentile form.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating rank for Series.
Aggregating rank for DataFrame.
Examples


Calculate the expanding standard error of mean.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating sem for Series.
Aggregating sem for DataFrame.
Notes
A minimum of one period is required for the calculation.
Examples


Calculate the expanding unbiased skewness.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Third moment of a probability density.
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating skew for Series.
Aggregating skew for DataFrame.
Notes
A minimum of three periods is required for the rolling calculation.


Calculate the expanding standard deviation.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.4.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.4.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Equivalent method for NumPy array.
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating std for Series.
Aggregating std for DataFrame.
Notes
The default ddof of 1 used in Series.std() is different than the default ddof of 0 in numpy.std().
A minimum of one period is required for the rolling calculation.
Examples


Calculate the expanding sum.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating sum for Series.
Aggregating sum for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.


Calculate the expanding variance.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.4.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.4.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Equivalent method for NumPy array.
Calling expanding with Series data.
Calling expanding with DataFrames.
Aggregating var for Series.
Aggregating var for DataFrame.
Notes
The default ddof of 1 used in Series.var() is different than the default ddof of 0 in numpy.var().
A minimum of one period is required for the rolling calculation.
Examples


Aggregate using one or more operations over the specified axis.
Function to use for aggregating the data. If a function, must either work when passed a Series/Dataframe or when passed to Series/Dataframe.apply.
Accepted combinations are:
function
string function name
list of functions and/or function names, e.g. [np.sum, 'mean']
dict of axis labels -> functions, function names or list of such.
Positional arguments to pass to func.
Keyword arguments to pass to func.
The return can be:
scalar : when Series.agg is called with single function
Series : when DataFrame.agg is called with a single function
DataFrame : when DataFrame.agg is called with several functions
Return scalar, Series or DataFrame.
See also
Calling object with Series data.
Calling object with DataFrame data.
Notes
agg is an alias for aggregate. Use the alias.
Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methods for more details.
A passed user-defined-function will be passed a Series for evaluation.
Examples


Calculate the rolling custom aggregation function.
Must produce a single value from an ndarray input if raw=True or a single value from a Series if raw=False. Can also accept a Numba JIT function with engine='numba' specified.
Changed in version 1.0.0.
False : passes each row or column as a Series to the function.
True : the passed function will receive ndarray objects instead. If you are just applying a NumPy reduction function this will achieve much better performance.
'cython' : Runs rolling apply through C-extensions from cython.
'numba' : Runs rolling apply through JIT compiled code from numba. Only available when raw is set to True.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.0.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False} and will be applied to both the func and the apply rolling aggregation.
New in version 1.0.0.
Positional arguments to be passed into func.
Keyword arguments to be passed into func.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating apply for Series.
Aggregating apply for DataFrame.


Calculate the rolling correlation.
If not supplied then will default to self and produce pairwise output.
If False then only matching columns between self and other will be used and the output will be a DataFrame. If True then all pairwise combinations will be calculated and the output will be a MultiIndexed DataFrame in the case of DataFrame inputs. In the case of missing elements, only complete pairwise observations will be used.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Similar method to calculate covariance.
NumPy Pearson’s correlation calculation.
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating corr for Series.
Aggregating corr for DataFrame.
Notes
This function uses Pearson’s definition of correlation (https://en.wikipedia.org/wiki/Pearson_correlation_coefficient).
When other is not specified, the output will be self correlation (e.g. all 1’s), except for DataFrame inputs with pairwise set to True.
Function will return NaN for correlations of equal valued sequences; this is the result of a 0/0 division error.
When pairwise is set to False, only matching columns between self and other will be used.
When pairwise is set to True, the output will be a MultiIndex DataFrame with the original index on the first level, and the other DataFrame columns on the second level.
In the case of missing elements, only complete pairwise observations will be used.
Examples
The below example shows a rolling calculation with a window size of four matching the equivalent function call using numpy.corrcoef().
The below example shows a similar rolling calculation on a DataFrame using the pairwise option.


Calculate the rolling count of non NaN observations.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating count for Series.
Aggregating count for DataFrame.
Examples


Calculate the rolling sample covariance.
If not supplied then will default to self and produce pairwise output.
If False then only matching columns between self and other will be used and the output will be a DataFrame. If True then all pairwise combinations will be calculated and the output will be a MultiIndexed DataFrame in the case of DataFrame inputs. In the case of missing elements, only complete pairwise observations will be used.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating cov for Series.
Aggregating cov for DataFrame.


Calculate the rolling Fisher’s definition of kurtosis without bias.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Reference SciPy method.
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating kurt for Series.
Aggregating kurt for DataFrame.
Notes
A minimum of four periods is required for the calculation.
Examples
The example below will show a rolling calculation with a window size of four matching the equivalent function call using scipy.stats.


Calculate the rolling maximum.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating max for Series.
Aggregating max for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.


Calculate the rolling mean.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating mean for Series.
Aggregating mean for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.
Examples
The below examples will show rolling mean calculations with window sizes of two and three, respectively.


Calculate the rolling median.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating median for Series.
Aggregating median for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.
Examples
Compute the rolling median of a series with a window size of 3.


Calculate the rolling minimum.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating min for Series.
Aggregating min for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.
Examples
Performing a rolling minimum with a window size of 3.


Calculate the rolling quantile.
Quantile to compute. 0 <= quantile <= 1.
This optional parameter specifies the interpolation method to use, when the desired quantile lies between two data points i and j:
linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.
lower: i.
higher: j.
nearest: i or j whichever is nearest.
midpoint: (i + j) / 2.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating quantile for Series.
Aggregating quantile for DataFrame.
Examples


Calculate the rolling rank.
New in version 1.4.0.
How to rank the group of records that have the same value (i.e. ties):
average: average rank of the group
min: lowest rank in the group
max: highest rank in the group
Whether or not the elements should be ranked in ascending order.
Whether or not to display the returned rankings in percentile form.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating rank for Series.
Aggregating rank for DataFrame.
Examples


Calculate the rolling standard error of mean.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating sem for Series.
Aggregating sem for DataFrame.
Notes
A minimum of one period is required for the calculation.
Examples


Calculate the rolling unbiased skewness.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Third moment of a probability density.
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating skew for Series.
Aggregating skew for DataFrame.
Notes
A minimum of three periods is required for the rolling calculation.


Calculate the rolling standard deviation.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.4.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.4.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Equivalent method for NumPy array.
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating std for Series.
Aggregating std for DataFrame.
Notes
The default ddof of 1 used in Series.std() is different than the default ddof of 0 in numpy.std().
A minimum of one period is required for the rolling calculation.
The implementation is susceptible to floating point imprecision as shown in the example below.
Examples


Calculate the rolling sum.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.3.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.3.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating sum for Series.
Aggregating sum for DataFrame.
Notes
See Numba engine and Numba (JIT compilation) for extended documentation and performance considerations for the Numba engine.
Examples
For DataFrame, each sum is computed column-wise.


Calculate the rolling variance.
Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
For NumPy compatibility and will not have an effect on the result.
'cython' : Runs the operation through C-extensions from cython.
'numba' : Runs the operation through JIT compiled code from numba.
None : Defaults to 'cython' or globally setting compute.use_numba
New in version 1.4.0.
For 'cython' engine, there are no accepted engine_kwargs
For 'numba' engine, the engine can accept nopython, nogil and parallel dictionary keys. The values must either be True or False. The default engine_kwargs for the 'numba' engine is {'nopython': True, 'nogil': False, 'parallel': False}
New in version 1.4.0.
For NumPy compatibility and will not have an effect on the result.
Return type is the same as the original object with np.float64 dtype.
See also
Equivalent method for NumPy array.
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating var for Series.
Aggregating var for DataFrame.
Notes
The default ddof of 1 used in Series.var() is different than the default ddof of 0 in numpy.var().
A minimum of one period is required for the rolling calculation.
The implementation is susceptible to floating point imprecision as shown in the example below.
Examples


Calculate the rolling weighted window mean.
Keyword arguments to configure the SciPy weighted window type.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating mean for Series.
Aggregating mean for DataFrame.


Calculate the rolling weighted window standard deviation.
New in version 1.0.0.
Keyword arguments to configure the SciPy weighted window type.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating std for Series.
Aggregating std for DataFrame.


Calculate the rolling weighted window sum.
Keyword arguments to configure the SciPy weighted window type.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating sum for Series.
Aggregating sum for DataFrame.


Calculate the rolling weighted window variance.
New in version 1.0.0.
Keyword arguments to configure the SciPy weighted window type.
Return type is the same as the original object with np.float64 dtype.
See also
Calling rolling with Series data.
Calling rolling with DataFrames.
Aggregating var for Series.
Aggregating var for DataFrame.


Compute a simple cross tabulation of two (or more) factors. By default computes a frequency table of the factors unless an array of values and an aggregation function are passed.
Values to group by in the rows.
Values to group by in the columns.
Array of values to aggregate according to the factors. Requires aggfunc be specified.
If passed, must match number of row arrays passed.
If passed, must match number of column arrays passed.
If specified, requires values be specified as well.
Add row/column margins (subtotals).
Name of the row/column that will contain the totals when margins is True.
Do not include columns whose entries are all NaN.
Normalize by dividing all values by the sum of values.
If passed ‘all’ or True, will normalize over all values.
If passed ‘index’ will normalize over each row.
If passed ‘columns’ will normalize over each column.
If margins is True, will also normalize margin values.
Cross tabulation of the data.
See also
Reshape data based on column values.
Create a pivot table as a DataFrame.
Notes
Any Series passed will have their name attributes used unless row or column names for the cross-tabulation are specified.
Any input passed containing Categorical data will have all of its categories included in the cross-tabulation, even if the actual data does not contain any instances of a particular category.
In the event that there aren’t overlapping indexes an empty DataFrame will be returned.
Examples
Here ‘c’ and ‘f’ are not represented in the data and will not be shown in the output because dropna is True by default. Set dropna=False to preserve categories with no data.


Bin values into discrete intervals.
Use cut when you need to segment and sort data values into bins. This function is also useful for going from a continuous variable to a categorical variable. For example, cut could convert ages to groups of age ranges. Supports binning into an equal number of bins, or a pre-specified array of bins.
The input array to be binned. Must be 1-dimensional.
The criteria to bin by.
int : Defines the number of equal-width bins in the range of x. The range of x is extended by .1% on each side to include the minimum and maximum values of x.
sequence of scalars : Defines the bin edges allowing for non-uniform width. No extension of the range of x is done.
IntervalIndex : Defines the exact bins to be used. Note that IntervalIndex for bins must be non-overlapping.
Indicates whether bins includes the rightmost edge or not. If right == True (the default), then the bins [1, 2, 3, 4] indicate (1,2], (2,3], (3,4]. This argument is ignored when bins is an IntervalIndex.
Specifies the labels for the returned bins. Must be the same length as the resulting bins. If False, returns only integer indicators of the bins. This affects the type of the output container (see below). This argument is ignored when bins is an IntervalIndex. If True, raises an error. When ordered=False, labels must be provided.
Whether to return the bins or not. Useful when bins is provided as a scalar.
The precision at which to store and display the bins labels.
Whether the first interval should be left-inclusive or not.
If bin edges are not unique, raise ValueError or drop non-uniques.
Whether the labels are ordered or not. Applies to returned types Categorical and Series (with Categorical dtype). If True, the resulting categorical will be ordered. If False, the resulting categorical will be unordered (labels must be provided).
New in version 1.1.0.
An array-like object representing the respective bin for each value of x. The type depends on the value of labels.
None (default) : returns a Series for Series x or a Categorical for all other inputs. The values stored within are Interval dtype.
sequence of scalars : returns a Series for Series x or a Categorical for all other inputs. The values stored within are whatever the type in the sequence is.
False : returns an ndarray of integers.
The computed or specified bins. Only returned when retbins=True. For scalar or sequence bins, this is an ndarray with the computed bins. If set duplicates=drop, bins will drop non-unique bin. For an IntervalIndex bins, this is equal to bins.
See also
Discretize variable into equal-sized buckets based on rank or based on sample quantiles.
Array type for storing data that come from a fixed set of values.
One-dimensional array with axis labels (including time series).
Immutable Index implementing an ordered, sliceable set.
Notes
Any NA values will be NA in the result. Out of bounds values will be NA in the resulting Series or Categorical object.
Examples
Discretize into three equal-sized bins.
Discovers the same bins, but assign them specific labels. Notice that the returned Categorical’s categories are labels and is ordered.
ordered=False will result in unordered categories when labels are passed. This parameter can be used to allow non-unique labels:
labels=False implies you just want the bins back.
Passing a Series as an input returns a Series with categorical dtype:
Passing a Series as an input returns a Series with mapping value. It is used to map numerically to intervals based on bins.
Use drop optional when bins is not unique
Passing an IntervalIndex for bins results in those categories exactly. Notice that values not covered by the IntervalIndex are set to NaN. 0 is to the left of the first bin (which is closed on the right), and 1.5 falls between two bins.