Two-dimensional, size-mutable, potentially heterogeneous tabular data.
Data structure also contains labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects. The primary pandas data structure.
Dict can contain Series, arrays, constants, dataclass or list-like objects. If data is a dict, column order follows insertion-order. If a dict contains Series which have an index defined, it is aligned by its index.
Changed in version 0.25.0: If data is a list of dicts, column order follows insertion-order.
Index to use for resulting frame. Will default to RangeIndex if no indexing information part of input data and no index provided.
Column labels to use for resulting frame when data does not have them, defaulting to RangeIndex(0, 1, 2, …, n). If data contains column labels, will perform column selection instead.
Data type to force. Only a single dtype is allowed. If None, infer.
Copy data from inputs. For dict data, the default of None behaves like copy=True. For DataFrame or 2d ndarray input, the default of None behaves like copy=False.
Changed in version 1.3.0.
See also
Constructor from tuples, also record arrays.
From dicts of Series, arrays, or dicts.
Read a comma-separated values (csv) file into DataFrame.
Read general delimited file into DataFrame.
Read text from clipboard into DataFrame.
Examples
Constructing DataFrame from a dictionary.
Notice that the inferred dtype is int64.
To enforce a single dtype:
Constructing DataFrame from a dictionary including Series:
Constructing DataFrame from numpy ndarray:
Constructing DataFrame from a numpy ndarray that has labeled columns:
Constructing DataFrame from dataclass:
Attributes
at
Access a single value for a row/column label pair.
attrs
Dictionary of global attributes of this dataset.
axes
Return a list representing the axes of the DataFrame.
columns
The column labels of the DataFrame.
dtypes
Return the dtypes in the DataFrame.
empty
Indicator whether Series/DataFrame is empty.
flags
Get the properties associated with this pandas object.
iat
Access a single value for a row/column pair by integer position.
iloc
Purely integer-location based indexing for selection by position.
index
The index (row labels) of the DataFrame.
loc
Access a group of rows and columns by label(s) or a boolean array.
ndim
Return an int representing the number of axes / array dimensions.
shape
Return a tuple representing the dimensionality of the DataFrame.
size
Return an int representing the number of elements in this object.
style
Returns a Styler object.
values
Return a Numpy representation of the DataFrame.
T
Methods
abs()
Return a Series/DataFrame with absolute numeric value of each element.
add(other[, axis, level, fill_value])
Get Addition of dataframe and other, element-wise (binary operator add).
add_prefix(prefix)
Prefix labels with string prefix.
add_suffix(suffix)
Suffix labels with string suffix.
agg([func, axis])
Aggregate using one or more operations over the specified axis.
aggregate([func, axis])
Aggregate using one or more operations over the specified axis.
align(other[, join, axis, level, copy, ...])
Align two objects on their axes with the specified join method.
all([axis, bool_only, skipna, level])
Return whether all elements are True, potentially over an axis.
any([axis, bool_only, skipna, level])
Return whether any element is True, potentially over an axis.
append(other[, ignore_index, ...])
Append rows of other to the end of caller, returning a new object.
apply(func[, axis, raw, result_type, args])
Apply a function along an axis of the DataFrame.
applymap(func[, na_action])
Apply a function to a Dataframe elementwise.
asfreq(freq[, method, how, normalize, ...])
Convert time series to specified frequency.
asof(where[, subset])
Return the last row(s) without any NaNs before where.
assign(**kwargs)
Assign new columns to a DataFrame.
astype(dtype[, copy, errors])
Cast a pandas object to a specified dtype dtype.
at_time(time[, asof, axis])
Select values at particular time of day (e.g., 9:30AM).
backfill([axis, inplace, limit, downcast])
Synonym for DataFrame.fillna() with method='bfill'.
between_time(start_time, end_time[, ...])
Select values between particular times of the day (e.g., 9:00-9:30 AM).
bfill([axis, inplace, limit, downcast])
Synonym for DataFrame.fillna() with method='bfill'.
bool()
Return the bool of a single element Series or DataFrame.
boxplot([column, by, ax, fontsize, rot, ...])
Make a box plot from DataFrame columns.
clip([lower, upper, axis, inplace])
Trim values at input threshold(s).
combine(other, func[, fill_value, overwrite])
Perform column-wise combine with another DataFrame.
combine_first(other)
Update null elements with value in the same location in other.
compare(other[, align_axis, keep_shape, ...])
Compare to another DataFrame and show the differences.
convert_dtypes([infer_objects, ...])
Convert columns to best possible dtypes using dtypes supporting pd.NA.
copy([deep])
Make a copy of this object's indices and data.
corr([method, min_periods])
Compute pairwise correlation of columns, excluding NA/null values.
corrwith(other[, axis, drop, method])
Compute pairwise correlation.
count([axis, level, numeric_only])
Count non-NA cells for each column or row.
cov([min_periods, ddof])
Compute pairwise covariance of columns, excluding NA/null values.
cummax([axis, skipna])
Return cumulative maximum over a DataFrame or Series axis.
cummin([axis, skipna])
Return cumulative minimum over a DataFrame or Series axis.
cumprod([axis, skipna])
Return cumulative product over a DataFrame or Series axis.
cumsum([axis, skipna])
Return cumulative sum over a DataFrame or Series axis.
describe([percentiles, include, exclude, ...])
Generate descriptive statistics.
diff([periods, axis])
First discrete difference of element.
div(other[, axis, level, fill_value])
Get Floating division of dataframe and other, element-wise (binary operator truediv).
divide(other[, axis, level, fill_value])
Get Floating division of dataframe and other, element-wise (binary operator truediv).
dot(other)
Compute the matrix multiplication between the DataFrame and other.
drop([labels, axis, index, columns, level, ...])
Drop specified labels from rows or columns.
drop_duplicates([subset, keep, inplace, ...])
Return DataFrame with duplicate rows removed.
droplevel(level[, axis])
Return Series/DataFrame with requested index / column level(s) removed.
dropna([axis, how, thresh, subset, inplace])
Remove missing values.
duplicated([subset, keep])
Return boolean Series denoting duplicate rows.
eq(other[, axis, level])
Get Equal to of dataframe and other, element-wise (binary operator eq).
equals(other)
Test whether two objects contain the same elements.
eval(expr[, inplace])
Evaluate a string describing operations on DataFrame columns.
ewm([com, span, halflife, alpha, ...])
Provide exponentially weighted (EW) calculations.
expanding([min_periods, center, axis, method])
Provide expanding window calculations.
explode(column[, ignore_index])
Transform each element of a list-like to a row, replicating index values.
ffill([axis, inplace, limit, downcast])
Synonym for DataFrame.fillna() with method='ffill'.
fillna([value, method, axis, inplace, ...])
Fill NA/NaN values using the specified method.
filter([items, like, regex, axis])
Subset the dataframe rows or columns according to the specified index labels.
first(offset)
Select initial periods of time series data based on a date offset.
first_valid_index()
Return index for first non-NA value or None, if no NA value is found.
floordiv(other[, axis, level, fill_value])
Get Integer division of dataframe and other, element-wise (binary operator floordiv).
from_dict(data[, orient, dtype, columns])
Construct DataFrame from dict of array-like or dicts.
from_records(data[, index, exclude, ...])
Convert structured or record ndarray to DataFrame.
ge(other[, axis, level])
Get Greater than or equal to of dataframe and other, element-wise (binary operator ge).
get(key[, default])
Get item from object for given key (ex: DataFrame column).
groupby([by, axis, level, as_index, sort, ...])
Group DataFrame using a mapper or by a Series of columns.
gt(other[, axis, level])
Get Greater than of dataframe and other, element-wise (binary operator gt).
head([n])
Return the first n rows.
hist([column, by, grid, xlabelsize, xrot, ...])
Make a histogram of the DataFrame's columns.
idxmax([axis, skipna])
Return index of first occurrence of maximum over requested axis.
idxmin([axis, skipna])
Return index of first occurrence of minimum over requested axis.
infer_objects()
Attempt to infer better dtypes for object columns.
info([verbose, buf, max_cols, memory_usage, ...])
Print a concise summary of a DataFrame.
insert(loc, column, value[, allow_duplicates])
Insert column into DataFrame at specified location.
interpolate([method, axis, limit, inplace, ...])
Fill NaN values using an interpolation method.
isin(values)
Whether each element in the DataFrame is contained in values.
isna()
Detect missing values.
isnull()
DataFrame.isnull is an alias for DataFrame.isna.
items()
Iterate over (column name, Series) pairs.
iteritems()
Iterate over (column name, Series) pairs.
iterrows()
Iterate over DataFrame rows as (index, Series) pairs.
itertuples([index, name])
Iterate over DataFrame rows as namedtuples.
join(other[, on, how, lsuffix, rsuffix, sort])
Join columns of another DataFrame.
keys()
Get the 'info axis' (see Indexing for more).
kurt([axis, skipna, level, numeric_only])
Return unbiased kurtosis over requested axis.
kurtosis([axis, skipna, level, numeric_only])
Return unbiased kurtosis over requested axis.
last(offset)
Select final periods of time series data based on a date offset.
last_valid_index()
Return index for last non-NA value or None, if no NA value is found.
le(other[, axis, level])
Get Less than or equal to of dataframe and other, element-wise (binary operator le).
lookup(row_labels, col_labels)
(DEPRECATED) Label-based "fancy indexing" function for DataFrame.
lt(other[, axis, level])
Get Less than of dataframe and other, element-wise (binary operator lt).
mad([axis, skipna, level])
Return the mean absolute deviation of the values over the requested axis.
mask(cond[, other, inplace, axis, level, ...])
Replace values where the condition is True.
max([axis, skipna, level, numeric_only])
Return the maximum of the values over the requested axis.
mean([axis, skipna, level, numeric_only])
Return the mean of the values over the requested axis.
median([axis, skipna, level, numeric_only])
Return the median of the values over the requested axis.
melt([id_vars, value_vars, var_name, ...])
Unpivot a DataFrame from wide to long format, optionally leaving identifiers set.
memory_usage([index, deep])
Return the memory usage of each column in bytes.
merge(right[, how, on, left_on, right_on, ...])
Merge DataFrame or named Series objects with a database-style join.
min([axis, skipna, level, numeric_only])
Return the minimum of the values over the requested axis.
mod(other[, axis, level, fill_value])
Get Modulo of dataframe and other, element-wise (binary operator mod).
mode([axis, numeric_only, dropna])
Get the mode(s) of each element along the selected axis.
mul(other[, axis, level, fill_value])
Get Multiplication of dataframe and other, element-wise (binary operator mul).
multiply(other[, axis, level, fill_value])
Get Multiplication of dataframe and other, element-wise (binary operator mul).
ne(other[, axis, level])
Get Not equal to of dataframe and other, element-wise (binary operator ne).
nlargest(n, columns[, keep])
Return the first n rows ordered by columns in descending order.
notna()
Detect existing (non-missing) values.
notnull()
DataFrame.notnull is an alias for DataFrame.notna.
nsmallest(n, columns[, keep])
Return the first n rows ordered by columns in ascending order.
nunique([axis, dropna])
Count number of distinct elements in specified axis.
pad([axis, inplace, limit, downcast])
Synonym for DataFrame.fillna() with method='ffill'.
pct_change([periods, fill_method, limit, freq])
Percentage change between the current and a prior element.
pipe(func, *args, **kwargs)
Apply chainable functions that expect Series or DataFrames.
pivot([index, columns, values])
Return reshaped DataFrame organized by given index / column values.
pivot_table([values, index, columns, ...])
Create a spreadsheet-style pivot table as a DataFrame.
plot
alias of pandas.plotting._core.PlotAccessor
pop(item)
Return item and drop from frame.
pow(other[, axis, level, fill_value])
Get Exponential power of dataframe and other, element-wise (binary operator pow).
prod([axis, skipna, level, numeric_only, ...])
Return the product of the values over the requested axis.
product([axis, skipna, level, numeric_only, ...])
Return the product of the values over the requested axis.
quantile([q, axis, numeric_only, interpolation])
Return values at the given quantile over requested axis.
query(expr[, inplace])
Query the columns of a DataFrame with a boolean expression.
radd(other[, axis, level, fill_value])
Get Addition of dataframe and other, element-wise (binary operator radd).
rank([axis, method, numeric_only, ...])
Compute numerical data ranks (1 through n) along axis.
rdiv(other[, axis, level, fill_value])
Get Floating division of dataframe and other, element-wise (binary operator rtruediv).
reindex([labels, index, columns, axis, ...])
Conform Series/DataFrame to new index with optional filling logic.
reindex_like(other[, method, copy, limit, ...])
Return an object with matching indices as other object.
rename([mapper, index, columns, axis, copy, ...])
Alter axes labels.
rename_axis([mapper, index, columns, axis, ...])
Set the name of the axis for the index or columns.
reorder_levels(order[, axis])
Rearrange index levels using input order.
replace([to_replace, value, inplace, limit, ...])
Replace values given in to_replace with value.
resample(rule[, axis, closed, label, ...])
Resample time-series data.
reset_index([level, drop, inplace, ...])
Reset the index, or a level of it.
rfloordiv(other[, axis, level, fill_value])
Get Integer division of dataframe and other, element-wise (binary operator rfloordiv).
rmod(other[, axis, level, fill_value])
Get Modulo of dataframe and other, element-wise (binary operator rmod).
rmul(other[, axis, level, fill_value])
Get Multiplication of dataframe and other, element-wise (binary operator rmul).
rolling(window[, min_periods, center, ...])
Provide rolling window calculations.
round([decimals])
Round a DataFrame to a variable number of decimal places.
rpow(other[, axis, level, fill_value])
Get Exponential power of dataframe and other, element-wise (binary operator rpow).
rsub(other[, axis, level, fill_value])
Get Subtraction of dataframe and other, element-wise (binary operator rsub).
rtruediv(other[, axis, level, fill_value])
Get Floating division of dataframe and other, element-wise (binary operator rtruediv).
sample([n, frac, replace, weights, ...])
Return a random sample of items from an axis of object.
select_dtypes([include, exclude])
Return a subset of the DataFrame's columns based on the column dtypes.
sem([axis, skipna, level, ddof, numeric_only])
Return unbiased standard error of the mean over requested axis.
set_axis(labels[, axis, inplace])
Assign desired index to given axis.
set_flags(*[, copy, allows_duplicate_labels])
Return a new object with updated flags.
set_index(keys[, drop, append, inplace, ...])
Set the DataFrame index using existing columns.
shift([periods, freq, axis, fill_value])
Shift index by desired number of periods with an optional time freq.
skew([axis, skipna, level, numeric_only])
Return unbiased skew over requested axis.
slice_shift([periods, axis])
(DEPRECATED) Equivalent to shift without copying data.
sort_index([axis, level, ascending, ...])
Sort object by labels (along an axis).
sort_values(by[, axis, ascending, inplace, ...])
Sort by the values along either axis.
sparse
alias of pandas.core.arrays.sparse.accessor.SparseFrameAccessor
squeeze([axis])
Squeeze 1 dimensional axis objects into scalars.
stack([level, dropna])
Stack the prescribed level(s) from columns to index.
std([axis, skipna, level, ddof, numeric_only])
Return sample standard deviation over requested axis.
sub(other[, axis, level, fill_value])
Get Subtraction of dataframe and other, element-wise (binary operator sub).
subtract(other[, axis, level, fill_value])
Get Subtraction of dataframe and other, element-wise (binary operator sub).
sum([axis, skipna, level, numeric_only, ...])
Return the sum of the values over the requested axis.
swapaxes(axis1, axis2[, copy])
Interchange axes and swap values axes appropriately.
swaplevel([i, j, axis])
Swap levels i and j in a MultiIndex.
tail([n])
Return the last n rows.
take(indices[, axis, is_copy])
Return the elements in the given positional indices along an axis.
to_clipboard([excel, sep])
Copy object to the system clipboard.
to_csv([path_or_buf, sep, na_rep, ...])
Write object to a comma-separated values (csv) file.
to_dict([orient, into])
Convert the DataFrame to a dictionary.
to_excel(excel_writer[, sheet_name, na_rep, ...])
Write object to an Excel sheet.
to_feather(path, **kwargs)
Write a DataFrame to the binary Feather format.
to_gbq(destination_table[, project_id, ...])
Write a DataFrame to a Google BigQuery table.
to_hdf(path_or_buf, key[, mode, complevel, ...])
Write the contained data to an HDF5 file using HDFStore.
to_html([buf, columns, col_space, header, ...])
Render a DataFrame as an HTML table.
to_json([path_or_buf, orient, date_format, ...])
Convert the object to a JSON string.
to_latex([buf, columns, col_space, header, ...])
Render object to a LaTeX tabular, longtable, or nested table.
to_markdown([buf, mode, index, storage_options])
Print DataFrame in Markdown-friendly format.
to_numpy([dtype, copy, na_value])
Convert the DataFrame to a NumPy array.
to_parquet([path, engine, compression, ...])
Write a DataFrame to the binary parquet format.
to_period([freq, axis, copy])
Convert DataFrame from DatetimeIndex to PeriodIndex.
to_pickle(path[, compression, protocol, ...])
Pickle (serialize) object to file.
to_records([index, column_dtypes, index_dtypes])
Convert DataFrame to a NumPy record array.
to_sql(name, con[, schema, if_exists, ...])
Write records stored in a DataFrame to a SQL database.
to_stata(path[, convert_dates, write_index, ...])
Export DataFrame object to Stata dta format.
to_string([buf, columns, col_space, header, ...])
Render a DataFrame to a console-friendly tabular output.
to_timestamp([freq, how, axis, copy])
Cast to DatetimeIndex of timestamps, at beginning of period.
to_xarray()
Return an xarray object from the pandas object.
to_xml([path_or_buffer, index, root_name, ...])
Render a DataFrame to an XML document.
transform(func[, axis])
Call func on self producing a DataFrame with the same axis shape as self.
transpose(*args[, copy])
Transpose index and columns.
truediv(other[, axis, level, fill_value])
Get Floating division of dataframe and other, element-wise (binary operator truediv).
truncate([before, after, axis, copy])
Truncate a Series or DataFrame before and after some index value.
tshift([periods, freq, axis])
(DEPRECATED) Shift the time index, using the index's frequency if available.
tz_convert(tz[, axis, level, copy])
Convert tz-aware axis to target time zone.
tz_localize(tz[, axis, level, copy, ...])
Localize tz-naive index of a Series or DataFrame to target time zone.
unstack([level, fill_value])
Pivot a level of the (necessarily hierarchical) index labels.
update(other[, join, overwrite, ...])
Modify in place using non-NA values from another DataFrame.
value_counts([subset, normalize, sort, ...])
Return a Series containing counts of unique rows in the DataFrame.
var([axis, skipna, level, ddof, numeric_only])
Return unbiased variance over requested axis.
where(cond[, other, inplace, axis, level, ...])
Replace values where the condition is False.
xs(key[, axis, level, drop_level])
Return cross-section from the Series/DataFrame.


Iterate over info axis.
Info axis as iterator.


Return a Series/DataFrame with absolute numeric value of each element.
This function only applies to elements that are all numeric.
Series/DataFrame containing the absolute value of each element.
See also
Calculate the absolute value element-wise.
Notes
For complex inputs, 1.2 + 1j, the absolute value is \(\sqrt{ a^2 + b^2 }\).
Examples
Absolute numeric values in a Series.
Absolute numeric values in a Series with complex numbers.
Absolute numeric values in a Series with a Timedelta element.
Select rows with data closest to certain value using argsort (from StackOverflow).


Get Addition of dataframe and other, element-wise (binary operator add).
Equivalent to dataframe + other, but with support to substitute a fill_value for missing data in one of the inputs. With reverse version, radd.
Among flexible wrappers (add, sub, mul, div, mod, pow) to arithmetic operators: +, -, *, /, //, %, **.
Any single or multiple element data structure, or list-like object.
Whether to compare by the index (0 or ‘index’) or columns (1 or ‘columns’). For Series input, axis to match Series index on.
Broadcast across a level, matching Index values on the passed MultiIndex level.
Fill existing missing (NaN) values, and any new element needed for successful DataFrame alignment, with this value before computation. If data in both corresponding DataFrame locations is missing the result will be missing.
Result of the arithmetic operation.
See also
Add DataFrames.
Subtract DataFrames.
Multiply DataFrames.
Divide DataFrames (float division).
Divide DataFrames (float division).
Divide DataFrames (integer division).
Calculate modulo (remainder after division).
Calculate exponential power.
Notes
Mismatched indices will be unioned together.
Examples
Add a scalar with operator version which return the same results.
Divide by constant with reverse version.
Subtract a list and Series by axis with operator version.
Multiply a DataFrame of different shape with operator version.
Divide by a MultiIndex by level.


Prefix labels with string prefix.
For Series, the row labels are prefixed. For DataFrame, the column labels are prefixed.
The string to add before each label.
New Series or DataFrame with updated labels.
See also
Suffix row labels with string suffix.
Suffix column labels with string suffix.
Examples


Suffix labels with string suffix.
For Series, the row labels are suffixed. For DataFrame, the column labels are suffixed.
The string to add after each label.
New Series or DataFrame with updated labels.
See also
Prefix row labels with string prefix.
Prefix column labels with string prefix.
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 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.
If 0 or ‘index’: apply function to each column. If 1 or ‘columns’: apply function to each row.
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
Perform any type of operations.
Perform transformation type operations.
Perform operations over groups.
Perform operations over resampled bins.
Perform operations over rolling window.
Perform operations over expanding window.
Perform operation over exponential weighted window.
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
Aggregate these functions over the rows.
Different aggregations per column.
Aggregate different functions over the columns and rename the index of the resulting DataFrame.
Aggregate over the columns.


Align two objects on their axes with the specified join method.
Join method is specified for each axis Index.
Align on index (0), columns (1), or both (None).
Broadcast across a level, matching Index values on the passed MultiIndex level.
Always returns new objects. If copy=False and no reindexing is required then original objects are returned.
Value to use for missing values. Defaults to NaN, but can be any “compatible” value.
Method to use for filling holes in reindexed Series:
pad / ffill: propagate last valid observation forward to next valid.
backfill / bfill: use NEXT valid observation to fill gap.
If method is specified, this is the maximum number of consecutive NaN values to forward/backward fill. In other words, if there is a gap with more than this number of consecutive NaNs, it will only be partially filled. If method is not specified, this is the maximum number of entries along the entire axis where NaNs will be filled. Must be greater than 0 if not None.
Filling axis, method and limit.
Broadcast values along this axis, if aligning two objects of different dimensions.
Aligned objects.
Examples
Align on columns:
We can also align on the index:
Finally, the default axis=None will align on both index and columns:


Return whether all elements are True, potentially over an axis.
Returns True unless there at least one element within a series or along a Dataframe axis that is False or equivalent (e.g. zero or empty).
Indicate which axis or axes should be reduced.
0 / ‘index’ : reduce the index, return a Series whose index is the original column labels.
1 / ‘columns’ : reduce the columns, return a Series whose index is the original index.
None : reduce all axes, return a scalar.
Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series.
Exclude NA/null values. If the entire row/column is NA and skipna is True, then the result will be True, as for an empty row/column. If skipna is False, then NA are treated as True, because these are not equal to zero.
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series.
Additional keywords have no effect but might be accepted for compatibility with NumPy.
If level is specified, then, DataFrame is returned; otherwise, Series is returned.
See also
Return True if all elements are True.
Return True if one (or more) elements are True.
Examples
Series
DataFrames
Create a dataframe from a dictionary.
Default behaviour checks if column-wise values all return True.
Specify axis='columns' to check if row-wise values all return True.
Or axis=None for whether every value is True.


Return whether any element is True, potentially over an axis.
Returns False unless there is at least one element within a series or along a Dataframe axis that is True or equivalent (e.g. non-zero or non-empty).
Indicate which axis or axes should be reduced.
0 / ‘index’ : reduce the index, return a Series whose index is the original column labels.
1 / ‘columns’ : reduce the columns, return a Series whose index is the original index.
None : reduce all axes, return a scalar.
Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series.
Exclude NA/null values. If the entire row/column is NA and skipna is True, then the result will be False, as for an empty row/column. If skipna is False, then NA are treated as True, because these are not equal to zero.
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series.
Additional keywords have no effect but might be accepted for compatibility with NumPy.
If level is specified, then, DataFrame is returned; otherwise, Series is returned.
See also
Numpy version of this method.
Return whether any element is True.
Return whether all elements are True.
Return whether any element is True over requested axis.
Return whether all elements are True over requested axis.
Examples
Series
For Series input, the output is a scalar indicating whether any element is True.
DataFrame
Whether each column contains at least one True element (the default).
Aggregating over the columns.
Aggregating over the entire DataFrame with axis=None.
any for an empty DataFrame is an empty Series.


Append rows of other to the end of caller, returning a new object.
Columns in other that are not in the caller are added as new columns.
The data to append.
If True, the resulting axis will be labeled 0, 1, …, n - 1.
If True, raise ValueError on creating index with duplicates.
Sort columns if the columns of self and other are not aligned.
Changed in version 1.0.0: Changed to not sort by default.
A new DataFrame consisting of the rows of caller and the rows of other.
See also
General function to concatenate DataFrame or Series objects.
Notes
If a list of dict/series is passed and the keys are all contained in the DataFrame’s index, the order of the columns in the resulting DataFrame will be unchanged.
Iteratively appending rows to a DataFrame can be more computationally intensive than a single concatenate. A better solution is to append those rows to a list and then concatenate the list with the original DataFrame all at once.
Examples
With ignore_index set to True:
The following, while not recommended methods for generating DataFrames, show two ways to generate a DataFrame from multiple data sources.
Less efficient:
More efficient:


Apply a function along an axis of the DataFrame.
Objects passed to the function are Series objects whose index is either the DataFrame’s index (axis=0) or the DataFrame’s columns (axis=1). By default (result_type=None), the final return type is inferred from the return type of the applied function. Otherwise, it depends on the result_type argument.
Function to apply to each column or row.
Axis along which the function is applied:
0 or ‘index’: apply function to each column.
1 or ‘columns’: apply function to each row.
Determines if row or column is passed as a Series or ndarray object:
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.
These only act when axis=1 (columns):
‘expand’ : list-like results will be turned into columns.
‘reduce’ : returns a Series if possible rather than expanding list-like results. This is the opposite of ‘expand’.
‘broadcast’ : results will be broadcast to the original shape of the DataFrame, the original index and columns will be retained.
The default behaviour (None) depends on the return value of the applied function: list-like results will be returned as a Series of those. However if the apply function returns a Series these are expanded to columns.
Positional arguments to pass to func in addition to the array/series.
Additional keyword arguments to pass as keywords arguments to func.
Result of applying func along the given axis of the DataFrame.
See also
For elementwise operations.
Only perform aggregating type operations.
Only perform transforming type operations.
Notes
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
Using a numpy universal function (in this case the same as np.sqrt(df)):
Using a reducing function on either axis
Returning a list-like will result in a Series
Passing result_type='expand' will expand list-like results to columns of a Dataframe
Returning a Series inside the function is similar to passing result_type='expand'. The resulting column names will be the Series index.
Passing result_type='broadcast' will ensure the same shape result, whether list-like or scalar is returned by the function, and broadcast it along the axis. The resulting column names will be the originals.


Apply a function to a Dataframe elementwise.
This method applies a function that accepts and returns a scalar to every element of a DataFrame.
Python function, returns a single value from a single value.
If ‘ignore’, propagate NaN values, without passing them to func.
New in version 1.2.
Additional keyword arguments to pass as keywords arguments to func.
New in version 1.3.0.
Transformed DataFrame.
See also
Apply a function along input axis of DataFrame.
Examples
Like Series.map, NA values can be ignored:
Note that a vectorized version of func often exists, which will be much faster. You could square each number elementwise.
But it’s better to avoid applymap in that case.


Convert time series to specified frequency.
Returns the original data conformed to a new index with the specified frequency.
If the index of this DataFrame is a PeriodIndex, the new index is the result of transforming the original index with PeriodIndex.asfreq (so the original index will map one-to-one to the new index).
Otherwise, the new index will be equivalent to pd.date_range(start, end,
freq=freq) where start and end are, respectively, the first and last entries in the original index (see pandas.date_range()). The values corresponding to any timesteps in the new index which were not present in the original index will be null (NaN), unless a method for filling such unknowns is provided (see the method parameter below).
The resample() method is more appropriate if an operation on each group of timesteps (such as an aggregate) is necessary to represent the data at the new frequency.
Frequency DateOffset or string.
Method to use for filling holes in reindexed Series (note this does not fill NaNs that already were present):
‘pad’ / ‘ffill’: propagate last valid observation forward to next valid
‘backfill’ / ‘bfill’: use NEXT valid observation to fill.
For PeriodIndex only (see PeriodIndex.asfreq).
Whether to reset output index to midnight.
Value to use for missing values, applied during upsampling (note this does not fill NaNs that already were present).
DataFrame object reindexed to the specified frequency.
See also
Conform DataFrame to new index with optional filling logic.
Notes
To learn more about the frequency strings, please see this link.
Examples
Start by creating a series with 4 one minute timestamps.
Upsample the series into 30 second bins.
Upsample again, providing a fill value.
Upsample again, providing a method.


Return the last row(s) without any NaNs before where.
The last row (for each element in where, if list) without any NaN is taken. In case of a DataFrame, the last row without NaN considering only the subset of columns (if not None)
If there is no good value, NaN is returned for a Series or a Series of NaN values for a DataFrame
Date(s) before which the last row(s) are returned.
For DataFrame, if not None, only use these columns to check for NaNs.
The return can be:
scalar : when self is a Series and where is a scalar
Series: when self is a Series and where is an array-like, or when self is a DataFrame and where is a scalar
DataFrame : when self is a DataFrame and where is an array-like
Return scalar, Series, or DataFrame.
See also
Perform an asof merge. Similar to left join.
Notes
Dates are assumed to be sorted. Raises if this is not the case.
Examples
A Series and a scalar where.
For a sequence where, a Series is returned. The first value is NaN, because the first element of where is before the first index value.
Missing values are not considered. The following is 2.0, not NaN, even though NaN is at the index location for 30.
Take all columns into consideration
Take a single column into consideration


Assign new columns to a DataFrame.
Returns a new object with all original columns in addition to new ones. Existing columns that are re-assigned will be overwritten.
The column names are keywords. If the values are callable, they are computed on the DataFrame and assigned to the new columns. The callable must not change input DataFrame (though pandas doesn’t check it). If the values are not callable, (e.g. a Series, scalar, or array), they are simply assigned.
A new DataFrame with the new columns in addition to all the existing columns.
Notes
Assigning multiple columns within the same assign is possible. Later items in ‘**kwargs’ may refer to newly created or modified columns in ‘df’; items are computed and assigned into ‘df’ in order.
Examples
Where the value is a callable, evaluated on df:
Alternatively, the same behavior can be achieved by directly referencing an existing Series or sequence:
You can create multiple columns within the same assign where one of the columns depends on another one defined within the same assign:


Cast a pandas object to a specified dtype dtype.
Use a numpy.dtype or Python type to cast entire pandas object to the same type. Alternatively, use {col: dtype, …}, where col is a column label and dtype is a numpy.dtype or Python type to cast one or more of the DataFrame’s columns to column-specific types.
Return a copy when copy=True (be very careful setting copy=False as changes to values then may propagate to other pandas objects).
Control raising of exceptions on invalid data for provided dtype.
raise : allow exceptions to be raised
ignore : suppress exceptions. On error return original object.
See also
Convert argument to datetime.
Convert argument to timedelta.
Convert argument to a numeric type.
Cast a numpy array to a specified type.
Notes
Deprecated since version 1.3.0: Using astype to convert from timezone-naive dtype to timezone-aware dtype is deprecated and will raise in a future version. Use Series.dt.tz_localize() instead.
Examples
Create a DataFrame:
Cast all columns to int32:
Cast col1 to int32 using a dictionary:
Create a series:
Convert to categorical type:
Convert to ordered categorical type with custom ordering:
Note that using copy=False and changing data on a new pandas object may propagate changes:
Create a series of dates:


Access a single value for a row/column label pair.
Similar to loc, in that both provide label-based lookups. Use at if you only need to get or set a single value in a DataFrame or Series.
If ‘label’ does not exist in DataFrame.
See also
Access a single value for a row/column pair by integer position.
Access a group of rows and columns by label(s).
Access a single value using a label.
Examples
Get value at specified row/column pair
Set value at specified row/column pair
Get value within a Series


Select values at particular time of day (e.g., 9:30AM).
If the index is not a DatetimeIndex
See also
Select values between particular times of the day.
Select initial periods of time series based on a date offset.
Select final periods of time series based on a date offset.
Get just the index locations for values at particular time of the day.
Examples


Dictionary of global attributes of this dataset.
Warning
attrs is experimental and may change without warning.
See also
Global flags applying to this object.


Return a list representing the axes of the DataFrame.
It has the row axis labels and column axis labels as the only members. They are returned in that order.
Examples


Synonym for DataFrame.fillna() with method='bfill'.
Object with missing values filled or None if inplace=True.


Select values between particular times of the day (e.g., 9:00-9:30 AM).
By setting start_time to be later than end_time, you can get the times that are not between the two times.
Initial time as a time filter limit.
End time as a time filter limit.
Whether the start time needs to be included in the result.
Deprecated since version 1.4.0: Arguments include_start and include_end have been deprecated to standardize boundary inputs. Use inclusive instead, to set each bound as closed or open.
Whether the end time needs to be included in the result.
Deprecated since version 1.4.0: Arguments include_start and include_end have been deprecated to standardize boundary inputs. Use inclusive instead, to set each bound as closed or open.
Include boundaries; whether to set each bound as closed or open.
Determine range time on index or columns value.
Data from the original object filtered to the specified dates range.
If the index is not a DatetimeIndex
See also
Select values at a particular time of the day.
Select initial periods of time series based on a date offset.
Select final periods of time series based on a date offset.
Get just the index locations for values between particular times of the day.
Examples
You get the times that are not between two times by setting start_time later than end_time:


Return the bool of a single element Series or DataFrame.
This must be a boolean scalar value, either True or False. It will raise a ValueError if the Series or DataFrame does not have exactly 1 element, or that element is not boolean (integer values 0 and 1 will also raise an exception).
The value in the Series or DataFrame.
See also
Change the data type of a Series, including to boolean.
Change the data type of a DataFrame, including to boolean.
NumPy boolean data type, used by pandas for boolean values.
Examples
The method will only work for single element objects with a boolean value:


Make a box plot from DataFrame columns.
Make a box-and-whisker plot from DataFrame columns, optionally grouped by some other columns. A box plot is a method for graphically depicting groups of numerical data through their quartiles. The box extends from the Q1 to Q3 quartile values of the data, with a line at the median (Q2). The whiskers extend from the edges of box to show the range of the data. By default, they extend no more than 1.5 * IQR (IQR = Q3 - Q1) from the edges of the box, ending at the farthest data point within that interval. Outliers are plotted as separate dots.
For further details see Wikipedia’s entry for boxplot.
Column name or list of names, or vector. Can be any valid input to pandas.DataFrame.groupby().
Column in the DataFrame to pandas.DataFrame.groupby(). One box-plot will be done per value of columns in by.
The matplotlib axes to be used by boxplot.
Tick label font size in points or as a string (e.g., large).
The rotation angle of labels (in degrees) with respect to the screen coordinate system.
Setting this to True will show the grid.
The size of the figure to create in matplotlib.
For example, (3, 5) will display the subplots using 3 columns and 5 rows, starting from the top-left.
The kind of object to return. The default is axes.
‘axes’ returns the matplotlib axes the boxplot is drawn on.
‘dict’ returns a dictionary whose values are the matplotlib Lines of the boxplot.
‘both’ returns a namedtuple with the axes and dict.
when grouping with by, a Series mapping columns to return_type is returned.
If return_type is None, a NumPy array of axes with the same shape as layout is returned.
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.
All other plotting keyword arguments to be passed to matplotlib.pyplot.boxplot().
See Notes.
See also
Make a histogram.
Matplotlib equivalent plot.
Notes
The return type depends on the return_type parameter:
‘axes’ : object of class matplotlib.axes.Axes
‘dict’ : dict of matplotlib.lines.Line2D objects
‘both’ : a namedtuple with structure (ax, lines)
For data grouped with by, return a Series of the above or a numpy array:
Series
array (for return_type = None)
Use return_type='dict' when you want to tweak the appearance of the lines after plotting. In this case a dict containing the Lines making up the boxes, caps, fliers, medians, and whiskers is returned.
Examples
Boxplots can be created for every column in the dataframe by df.boxplot() or indicating the columns to be used:
Boxplots of variables distributions grouped by the values of a third variable can be created using the option by. For instance:
A list of strings (i.e. ['X', 'Y']) can be passed to boxplot in order to group the data by combination of the variables in the x-axis:
The layout of boxplot can be adjusted giving a tuple to layout:
Additional formatting can be done to the boxplot, like suppressing the grid (grid=False), rotating the labels in the x-axis (i.e. rot=45) or changing the fontsize (i.e. fontsize=15):
The parameter return_type can be used to select the type of element returned by boxplot. When return_type='axes' is selected, the matplotlib axes on which the boxplot is drawn are returned:
When grouping with by, a Series mapping columns to return_type is returned:
If return_type is None, a NumPy array of axes with the same shape as layout is returned:


Trim values at input threshold(s).
Assigns values outside boundary to boundary values. Thresholds can be singular values or array like, and in the latter case the clipping is performed element-wise in the specified axis.
Minimum threshold value. All values below this threshold will be set to it. A missing threshold (e.g NA) will not clip the value.
Maximum threshold value. All values above this threshold will be set to it. A missing threshold (e.g NA) will not clip the value.
Align object with lower and upper along the given axis.
Whether to perform the operation in place on the data.
Additional keywords have no effect but might be accepted for compatibility with numpy.
Same type as calling object with the values outside the clip boundaries replaced or None if inplace=True.
See also
Trim values at input threshold in series.
Trim values at input threshold in dataframe.
Clip (limit) the values in an array.
Examples
Clips per column using lower and upper thresholds:
Clips using specific lower and upper thresholds per column element:
Clips using specific lower threshold per column element, with missing values:


Perform column-wise combine with another DataFrame.
Combines a DataFrame with other DataFrame using func to element-wise combine columns. The row and column indexes of the resulting DataFrame will be the union of the two.
The DataFrame to merge column-wise.
Function that takes two series as inputs and return a Series or a scalar. Used to merge the two dataframes column by columns.
The value to fill NaNs with prior to passing any column to the merge func.
If True, columns in self that do not exist in other will be overwritten with NaNs.
Combination of the provided DataFrames.
See also
Combine two DataFrame objects and default to non-null values in frame calling the method.
Examples
Combine using a simple function that chooses the smaller column.
Example using a true element-wise combine function.
Using fill_value fills Nones prior to passing the column to the merge function.
However, if the same element in both dataframes is None, that None is preserved
Example that demonstrates the use of overwrite and behavior when the axis differ between the dataframes.
Demonstrating the preference of the passed in dataframe.


Update null elements with value in the same location in other.
Combine two DataFrame objects by filling null values in one DataFrame with non-null values from other DataFrame. The row and column indexes of the resulting DataFrame will be the union of the two.
Provided DataFrame to use to fill null values.
The result of combining the provided DataFrame with the other object.
See also
Perform series-wise operation on two DataFrames using a given function.
Examples
Null values still persist if the location of that null value does not exist in other


Compare to another DataFrame and show the differences.
New in version 1.1.0.
Object to compare with.
Determine which axis to align the comparison on.
with rows drawn alternately from self and other.
with columns drawn alternately from self and other.
If true, all rows and columns are kept. Otherwise, only the ones with different values are kept.
If true, the result keeps values that are equal. Otherwise, equal values are shown as NaNs.
DataFrame that shows the differences stacked side by side.
The resulting index will be a MultiIndex with ‘self’ and ‘other’ stacked alternately at the inner level.
When the two DataFrames don’t have identical labels or shape.
See also
Compare with another Series and show differences.
Test whether two objects contain the same elements.
Notes
Matching NaNs will not appear as a difference.
Can only compare identically-labeled (i.e. same shape, identical row and column labels) DataFrames
Examples
Align the differences on columns
Stack the differences on rows
Keep the equal values
Keep all original rows and columns
Keep all original rows and columns and also all original values


Convert columns to best possible dtypes using dtypes supporting pd.NA.
New in version 1.0.0.
Whether object dtypes should be converted to the best possible types.
Whether object dtypes should be converted to StringDtype().
Whether, if possible, conversion can be done to integer extension types.
Whether object dtypes should be converted to BooleanDtypes().
Whether, if possible, conversion can be done to floating extension types. If convert_integer is also True, preference will be give to integer dtypes if the floats can be faithfully casted to integers.
New in version 1.2.0.
Copy of input object with new dtype.
See also
Infer dtypes of objects.
Convert argument to datetime.
Convert argument to timedelta.
Convert argument to a numeric type.
Notes
By default, convert_dtypes will attempt to convert a Series (or each Series in a DataFrame) to dtypes that support pd.NA. By using the options convert_string, convert_integer, convert_boolean and convert_boolean, it is possible to turn off individual conversions to StringDtype, the integer extension types, BooleanDtype or floating extension types, respectively.
For object-dtyped columns, if infer_objects is True, use the inference rules as during normal Series/DataFrame construction. Then, if possible, convert to StringDtype, BooleanDtype or an appropriate integer or floating extension type, otherwise leave as object.
If the dtype is integer, convert to an appropriate integer extension type.
If the dtype is numeric, and consists of all integers, convert to an appropriate integer extension type. Otherwise, convert to an appropriate floating extension type.
Changed in version 1.2: Starting with pandas 1.2, this method also converts float columns to the nullable floating extension type.
In the future, as new dtypes are added that support pd.NA, the results of this method will change to support those new dtypes.
Examples
Start with a DataFrame with default dtypes.
Convert the DataFrame to use best possible dtypes.
Start with a Series of strings and missing data represented by np.nan.
Obtain a Series with dtype StringDtype.


Make a copy of this object’s indices and data.
When deep=True (default), a new object will be created with a copy of the calling object’s data and indices. Modifications to the data or indices of the copy will not be reflected in the original object (see notes below).
When deep=False, a new object will be created without copying the calling object’s data or index (only references to the data and index are copied). Any changes to the data of the original will be reflected in the shallow copy (and vice versa).
Make a deep copy, including a copy of the data and the indices. With deep=False neither the indices nor the data are copied.
Object type matches caller.
Notes
When deep=True, data is copied but actual Python objects will not be copied recursively, only the reference to the object. This is in contrast to copy.deepcopy in the Standard Library, which recursively copies object data (see examples below).
While Index objects are copied when deep=True, the underlying numpy array is not copied for performance reasons. Since Index is immutable, the underlying data can be safely shared and a copy is not needed.
Examples
Shallow copy versus default (deep) copy:
Shallow copy shares data and index with original.
Deep copy has own copy of data and index.
Updates to the data shared by shallow copy and original is reflected in both; deep copy remains unchanged.
Note that when copying an object containing Python objects, a deep copy will copy the data, but will not do so recursively. Updating a nested data object will be reflected in the deep copy.


Compute pairwise correlation of columns, excluding NA/null values.
Method of correlation:
pearson : standard correlation coefficient
kendall : Kendall Tau correlation coefficient
spearman : Spearman rank correlation
and returning a float. Note that the returned matrix from corr will have 1 along the diagonals and will be symmetric regardless of the callable’s behavior.
Minimum number of observations required per pair of columns to have a valid result. Currently only available for Pearson and Spearman correlation.
Correlation matrix.
See also
Compute pairwise correlation with another DataFrame or Series.
Compute the correlation between two Series.
Examples


Compute pairwise correlation.
Pairwise correlation is computed between rows or columns of DataFrame with rows or columns of Series or DataFrame. DataFrames are first aligned along both axes before computing the correlations.
Object with which to compute correlations.
The axis to use. 0 or ‘index’ to compute column-wise, 1 or ‘columns’ for row-wise.
Drop missing indices from result.
Method of correlation:
pearson : standard correlation coefficient
kendall : Kendall Tau correlation coefficient
spearman : Spearman rank correlation
and returning a float.
Pairwise correlations.
See also
Compute pairwise correlation of columns.


Count non-NA cells for each column or row.
The values None, NaN, NaT, and optionally numpy.inf (depending on pandas.options.mode.use_inf_as_na) are considered NA.
If 0 or ‘index’ counts are generated for each column. If 1 or ‘columns’ counts are generated for each row.
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a DataFrame. A str specifies the level name.
Include only float, int or boolean data.
For each column/row the number of non-NA/null entries. If level is specified returns a DataFrame.
See also
Number of non-NA elements in a Series.
Count unique combinations of columns.
Number of DataFrame rows and columns (including NA elements).
Boolean same-sized DataFrame showing places of NA elements.
Examples
Constructing DataFrame from a dictionary:
Notice the uncounted NA values:
Counts for each row:


Compute pairwise covariance of columns, excluding NA/null values.
Compute the pairwise covariance among the series of a DataFrame. The returned data frame is the covariance matrix of the columns of the DataFrame.
Both NA and null values are automatically excluded from the calculation. (See the note below about bias from missing values.) A threshold can be set for the minimum number of observations for each value created. Comparisons with observations below this threshold will be returned as NaN.
This method is generally used for the analysis of time series data to understand the relationship between different measures across time.
Minimum number of observations required per pair of columns to have a valid result.
Delta degrees of freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
New in version 1.1.0.
The covariance matrix of the series of the DataFrame.
See also
Compute covariance with another Series.
Exponential weighted sample covariance.
Expanding sample covariance.
Rolling sample covariance.
Notes
Returns the covariance matrix of the DataFrame’s time series. The covariance is normalized by N-ddof.
For DataFrames that have Series that are missing data (assuming that data is missing at random) the returned covariance matrix will be an unbiased estimate of the variance and covariance between the member Series.
However, for many applications this estimate may not be acceptable because the estimate covariance matrix is not guaranteed to be positive semi-definite. This could lead to estimate correlations having absolute values which are greater than one, and/or a non-invertible covariance matrix. See Estimation of covariance matrices for more details.
Examples
Minimum number of periods
This method also supports an optional min_periods keyword that specifies the required minimum number of non-NA observations for each column pair in order to have a valid result:


Return cumulative maximum over a DataFrame or Series axis.
Returns a DataFrame or Series of the same size containing the cumulative maximum.
The index or the name of the axis. 0 is equivalent to None or ‘index’.
Exclude NA/null values. If an entire row/column is NA, the result will be NA.
Additional keywords have no effect but might be accepted for compatibility with NumPy.
Return cumulative maximum of Series or DataFrame.
See also
Similar functionality but ignores NaN values.
Return the maximum over DataFrame axis.
Return cumulative maximum over DataFrame axis.
Return cumulative minimum over DataFrame axis.
Return cumulative sum over DataFrame axis.
Return cumulative product over DataFrame axis.
Examples
Series
By default, NA values are ignored.
To include NA values in the operation, use skipna=False
DataFrame
By default, iterates over rows and finds the maximum in each column. This is equivalent to axis=None or axis='index'.
To iterate over columns and find the maximum in each row, use axis=1


Return cumulative minimum over a DataFrame or Series axis.
Returns a DataFrame or Series of the same size containing the cumulative minimum.
The index or the name of the axis. 0 is equivalent to None or ‘index’.
Exclude NA/null values. If an entire row/column is NA, the result will be NA.
Additional keywords have no effect but might be accepted for compatibility with NumPy.
Return cumulative minimum of Series or DataFrame.
See also
Similar functionality but ignores NaN values.
Return the minimum over DataFrame axis.
Return cumulative maximum over DataFrame axis.
Return cumulative minimum over DataFrame axis.
Return cumulative sum over DataFrame axis.
Return cumulative product over DataFrame axis.
Examples
Series
By default, NA values are ignored.
To include NA values in the operation, use skipna=False
DataFrame
By default, iterates over rows and finds the minimum in each column. This is equivalent to axis=None or axis='index'.
To iterate over columns and find the minimum in each row, use axis=1


Return cumulative product over a DataFrame or Series axis.
Returns a DataFrame or Series of the same size containing the cumulative product.
The index or the name of the axis. 0 is equivalent to None or ‘index’.
Exclude NA/null values. If an entire row/column is NA, the result will be NA.
Additional keywords have no effect but might be accepted for compatibility with NumPy.
Return cumulative product of Series or DataFrame.
See also
Similar functionality but ignores NaN values.
Return the product over DataFrame axis.
Return cumulative maximum over DataFrame axis.
Return cumulative minimum over DataFrame axis.
Return cumulative sum over DataFrame axis.
Return cumulative product over DataFrame axis.
Examples
Series
By default, NA values are ignored.
To include NA values in the operation, use skipna=False
DataFrame
By default, iterates over rows and finds the product in each column. This is equivalent to axis=None or axis='index'.
To iterate over columns and find the product in each row, use axis=1


Return cumulative sum over a DataFrame or Series axis.
Returns a DataFrame or Series of the same size containing the cumulative sum.
The index or the name of the axis. 0 is equivalent to None or ‘index’.
Exclude NA/null values. If an entire row/column is NA, the result will be NA.
Additional keywords have no effect but might be accepted for compatibility with NumPy.
Return cumulative sum of Series or DataFrame.
See also
Similar functionality but ignores NaN values.
Return the sum over DataFrame axis.
Return cumulative maximum over DataFrame axis.
Return cumulative minimum over DataFrame axis.
Return cumulative sum over DataFrame axis.
Return cumulative product over DataFrame axis.
Examples
Series
By default, NA values are ignored.
To include NA values in the operation, use skipna=False
DataFrame
By default, iterates over rows and finds the sum in each column. This is equivalent to axis=None or axis='index'.
To iterate over columns and find the sum in each row, use axis=1


Generate descriptive statistics.
Descriptive statistics include those that summarize the central tendency, dispersion and shape of a dataset’s distribution, excluding NaN values.
Analyzes both numeric and object series, as well as DataFrame column sets of mixed data types. The output will vary depending on what is provided. Refer to the notes below for more detail.
The percentiles to include in the output. All should fall between 0 and 1. The default is [.25, .5, .75], which returns the 25th, 50th, and 75th percentiles.
A white list of data types to include in the result. Ignored for Series. Here are the options:
‘all’ : All columns of the input will be included in the output.
A list-like of dtypes : Limits the results to the provided data types. To limit the result to numeric types submit numpy.number. To limit it instead to object columns submit the numpy.object data type. Strings can also be used in the style of select_dtypes (e.g. df.describe(include=['O'])). To select pandas categorical columns, use 'category'
None (default) : The result will include all numeric columns.
A black list of data types to omit from the result. Ignored for Series. Here are the options:
A list-like of dtypes : Excludes the provided data types from the result. To exclude numeric types submit numpy.number. To exclude object columns submit the data type numpy.object. Strings can also be used in the style of select_dtypes (e.g. df.describe(exclude=['O'])). To exclude pandas categorical columns, use 'category'
None (default) : The result will exclude nothing.
Whether to treat datetime dtypes as numeric. This affects statistics calculated for the column. For DataFrame input, this also controls whether datetime columns are included by default.
New in version 1.1.0.
Summary statistics of the Series or Dataframe provided.
See also
Count number of non-NA/null observations.
Maximum of the values in the object.
Minimum of the values in the object.
Mean of the values.
Standard deviation of the observations.
Subset of a DataFrame including/excluding columns based on their dtype.
Notes
For numeric data, the result’s index will include count, mean, std, min, max as well as lower, 50 and upper percentiles. By default the lower percentile is 25 and the upper percentile is 75. The 50 percentile is the same as the median.
For object data (e.g. strings or timestamps), the result’s index will include count, unique, top, and freq. The top is the most common value. The freq is the most common value’s frequency. Timestamps also include the first and last items.
If multiple object values have the highest count, then the count and top results will be arbitrarily chosen from among those with the highest count.
For mixed data types provided via a DataFrame, the default is to return only an analysis of numeric columns. If the dataframe consists only of object and categorical data without any numeric columns, the default is to return an analysis of both the object and categorical columns. If include='all' is provided as an option, the result will include a union of attributes of each type.
The include and exclude parameters can be used to limit which columns in a DataFrame are analyzed for the output. The parameters are ignored when analyzing a Series.
Examples
Describing a numeric Series.
Describing a categorical Series.
Describing a timestamp Series.
Describing a DataFrame. By default only numeric fields are returned.
Describing all columns of a DataFrame regardless of data type.
Describing a column from a DataFrame by accessing it as an attribute.
Including only numeric columns in a DataFrame description.
Including only string columns in a DataFrame description.
Including only categorical columns from a DataFrame description.
Excluding numeric columns from a DataFrame description.
Excluding object columns from a DataFrame description.


First discrete difference of element.
Calculates the difference of a Dataframe element compared with another element in the Dataframe (default is element in previous row).
Periods to shift for calculating difference, accepts negative values.
Take difference over rows (0) or columns (1).
First differences of the Series.
See also
Percent change over given number of periods.
Shift index by desired number of periods with an optional time freq.
First discrete difference of object.
Notes
For boolean dtypes, this uses operator.xor() rather than operator.sub(). The result is calculated according to current dtype in Dataframe, however dtype of the result is always float64.
Examples
Difference with previous row
Difference with previous column
Difference with 3rd previous row
Difference with following row
Overflow in input dtype


Get Floating division of dataframe and other, element-wise (binary operator truediv).
Equivalent to dataframe / other, but with support to substitute a fill_value for missing data in one of the inputs. With reverse version, rtruediv.
Among flexible wrappers (add, sub, mul, div, mod, pow) to arithmetic operators: +, -, *, /, //, %, **.
Any single or multiple element data structure, or list-like object.
Whether to compare by the index (0 or ‘index’) or columns (1 or ‘columns’). For Series input, axis to match Series index on.
Broadcast across a level, matching Index values on the passed MultiIndex level.
Fill existing missing (NaN) values, and any new element needed for successful DataFrame alignment, with this value before computation. If data in both corresponding DataFrame locations is missing the result will be missing.
Result of the arithmetic operation.
See also
Add DataFrames.
Subtract DataFrames.
Multiply DataFrames.
Divide DataFrames (float division).
Divide DataFrames (float division).
Divide DataFrames (integer division).
Calculate modulo (remainder after division).
Calculate exponential power.
Notes
Mismatched indices will be unioned together.
Examples
Add a scalar with operator version which return the same results.
Divide by constant with reverse version.
Subtract a list and Series by axis with operator version.
Multiply a DataFrame of different shape with operator version.
Divide by a MultiIndex by level.


Compute the matrix multiplication between the DataFrame and other.
This method computes the matrix product between the DataFrame and the values of an other Series, DataFrame or a numpy array.
It can also be called using self @ other in Python >= 3.5.
The other object to compute the matrix product with.
If other is a Series, return the matrix product between self and other as a Series. If other is a DataFrame or a numpy.array, return the matrix product of self and other in a DataFrame of a np.array.
See also
Similar method for Series.
Notes
The dimensions of DataFrame and other must be compatible in order to compute the matrix multiplication. In addition, the column names of DataFrame and the index of other must contain the same values, as they will be aligned prior to the multiplication.
The dot method for Series computes the inner product, instead of the matrix product here.
Examples
Here we multiply a DataFrame with a Series.
Here we multiply a DataFrame with another DataFrame.
Note that the dot method give the same result as @
The dot method works also if other is an np.array.
Note how shuffling of the objects does not change the result.


Drop specified labels from rows or columns.
Remove rows or columns by specifying label names and corresponding axis, or by specifying directly index or column names. When using a multi-index, labels on different levels can be removed by specifying the level. See the user guide <advanced.shown_levels> for more information about the now unused levels.
Index or column labels to drop. A tuple will be used as a single label and not treated as a list-like.
Whether to drop labels from the index (0 or ‘index’) or columns (1 or ‘columns’).
Alternative to specifying axis (labels, axis=0 is equivalent to index=labels).
Alternative to specifying axis (labels, axis=1 is equivalent to columns=labels).
For MultiIndex, level from which the labels will be removed.
If False, return a copy. Otherwise, do operation inplace and return None.
If ‘ignore’, suppress error and only existing labels are dropped.
DataFrame without the removed index or column labels or None if inplace=True.
If any of the labels is not found in the selected axis.
See also
Label-location based indexer for selection by label.
Return DataFrame with labels on given axis omitted where (all or any) data are missing.
Return DataFrame with duplicate rows removed, optionally only considering certain columns.
Return Series with specified index labels removed.
Examples
Drop columns
Drop a row by index
Drop columns and/or rows of MultiIndex DataFrame
Drop a specific index combination from the MultiIndex DataFrame, i.e., drop the combination 'falcon' and 'weight', which deletes only the corresponding row


Return DataFrame with duplicate rows removed.
Considering certain columns is optional. Indexes, including time indexes are ignored.
Only consider certain columns for identifying duplicates, by default use all of the columns.
Determines which duplicates (if any) to keep. - first : Drop duplicates except for the first occurrence. - last : Drop duplicates except for the last occurrence. - False : Drop all duplicates.
Whether to drop duplicates in place or to return a copy.
If True, the resulting axis will be labeled 0, 1, …, n - 1.
New in version 1.0.0.
DataFrame with duplicates removed or None if inplace=True.
See also
Count unique combinations of columns.
Examples
Consider dataset containing ramen rating.
By default, it removes duplicate rows based on all columns.
To remove duplicates on specific column(s), use subset.
To remove duplicates and keep last occurrences, use keep.


Return Series/DataFrame with requested index / column level(s) removed.
If a string is given, must be the name of a level If list-like, elements must be names or positional indexes of levels.
Axis along which the level(s) is removed:
0 or ‘index’: remove level(s) in column.
1 or ‘columns’: remove level(s) in row.
Series/DataFrame with requested index / column level(s) removed.
Examples


Remove missing values.
See the User Guide for more on which values are considered missing, and how to work with missing data.
Determine if rows or columns which contain missing values are removed.
0, or ‘index’ : Drop rows which contain missing values.
1, or ‘columns’ : Drop columns which contain missing value.
Changed in version 1.0.0: Pass tuple or list to drop on multiple axes. Only a single axis is allowed.
Determine if row or column is removed from DataFrame, when we have at least one NA or all NA.
‘any’ : If any NA values are present, drop that row or column.
‘all’ : If all values are NA, drop that row or column.
Require that many non-NA values.
Labels along other axis to consider, e.g. if you are dropping rows these would be a list of columns to include.
If True, do operation inplace and return None.
DataFrame with NA entries dropped from it or None if inplace=True.
See also
Indicate missing values.
Indicate existing (non-missing) values.
Replace missing values.
Drop missing values.
Drop missing indices.
Examples
Drop the rows where at least one element is missing.
Drop the columns where at least one element is missing.
Drop the rows where all elements are missing.
Keep only the rows with at least 2 non-NA values.
Define in which columns to look for missing values.
Keep the DataFrame with valid entries in the same variable.


Return the dtypes in the DataFrame.
This returns a Series with the data type of each column. The result’s index is the original DataFrame’s columns. Columns with mixed types are stored with the object dtype. See the User Guide for more.
The data type of each column.
Examples


Return boolean Series denoting duplicate rows.
Considering certain columns is optional.
Only consider certain columns for identifying duplicates, by default use all of the columns.
Determines which duplicates (if any) to mark.
first : Mark duplicates as True except for the first occurrence.
last : Mark duplicates as True except for the last occurrence.
False : Mark all duplicates as True.
Boolean series for each duplicated rows.
See also
Equivalent method on index.
Equivalent method on Series.
Remove duplicate values from Series.
Remove duplicate values from DataFrame.
Examples
Consider dataset containing ramen rating.
By default, for each set of duplicated values, the first occurrence is set on False and all others on True.
By using ‘last’, the last occurrence of each set of duplicated values is set on False and all others on True.
By setting keep on False, all duplicates are True.
To find duplicates on specific column(s), use subset.


Indicator whether Series/DataFrame is empty.
True if Series/DataFrame is entirely empty (no items), meaning any of the axes are of length 0.
If Series/DataFrame is empty, return True, if not return False.
See also
Return series without null values.
Return DataFrame with labels on given axis omitted where (all or any) data are missing.
Notes
If Series/DataFrame contains only NaNs, it is still not considered empty. See the example below.
Examples
An example of an actual empty DataFrame. Notice the index is empty:
If we only have NaNs in our DataFrame, it is not considered empty! We will need to drop the NaNs to make the DataFrame empty:


Get Equal to of dataframe and other, element-wise (binary operator eq).
Among flexible wrappers (eq, ne, le, lt, ge, gt) to comparison operators.
Equivalent to ==, !=, <=, <, >=, > with support to choose axis (rows or columns) and level for comparison.
Any single or multiple element data structure, or list-like object.
Whether to compare by the index (0 or ‘index’) or columns (1 or ‘columns’).
Broadcast across a level, matching Index values on the passed MultiIndex level.
Result of the comparison.
See also
Compare DataFrames for equality elementwise.
Compare DataFrames for inequality elementwise.
Compare DataFrames for less than inequality or equality elementwise.
Compare DataFrames for strictly less than inequality elementwise.
Compare DataFrames for greater than inequality or equality elementwise.
Compare DataFrames for strictly greater than inequality elementwise.
Notes
Mismatched indices will be unioned together. NaN values are considered different (i.e. NaN != NaN).
Examples
Comparison with a scalar, using either the operator or method:
When other is a Series, the columns of a DataFrame are aligned with the index of other and broadcast:
Use the method to control the broadcast axis:
When comparing to an arbitrary sequence, the number of columns must match the number elements in other:
Use the method to control the axis:
Compare to a DataFrame of different shape.
Compare to a MultiIndex by level.


Test whether two objects contain the same elements.
This function allows two Series or DataFrames to be compared against each other to see if they have the same shape and elements. NaNs in the same location are considered equal.
The row/column index do not need to have the same type, as long as the values are considered equal. Corresponding columns must be of the same dtype.
The other Series or DataFrame to be compared with the first.
True if all elements are the same in both objects, False otherwise.
See also
Compare two Series objects of the same length and return a Series where each element is True if the element in each Series is equal, False otherwise.
Compare two DataFrame objects of the same shape and return a DataFrame where each element is True if the respective element in each DataFrame is equal, False otherwise.
Raises an AssertionError if left and right are not equal. Provides an easy interface to ignore inequality in dtypes, indexes and precision among others.
Like assert_series_equal, but targets DataFrames.
Return True if two arrays have the same shape and elements, False otherwise.
Examples
DataFrames df and exactly_equal have the same types and values for their elements and column labels, which will return True.
DataFrames df and different_column_type have the same element types and values, but have different types for the column labels, which will still return True.
DataFrames df and different_data_type have different types for the same values for their elements, and will return False even though their column labels are the same values and types.


Evaluate a string describing operations on DataFrame columns.
Operates on columns only, not specific rows or elements. This allows eval to run arbitrary code, which can make you vulnerable to code injection if you pass user input to this function.
The expression string to evaluate.
If the expression contains an assignment, whether to perform the operation inplace and mutate the existing DataFrame. Otherwise, a new DataFrame is returned.
See the documentation for eval() for complete details on the keyword arguments accepted by query().
The result of the evaluation or None if inplace=True.
See also
Evaluates a boolean expression to query the columns of a frame.
Can evaluate an expression or function to create new values for a column.
Evaluate a Python expression as a string using various backends.
Notes
For more details see the API documentation for eval(). For detailed examples see enhancing performance with eval.
Examples
Assignment is allowed though by default the original DataFrame is not modified.
Use inplace=True to modify the original DataFrame.
Multiple columns can be assigned to using multi-line expressions:


Provide exponentially weighted (EW) calculations.
Exactly one parameter: com, span, halflife, or alpha must be provided.
Specify decay in terms of center of mass
\(\alpha = 1 / (1 + com)\), for \(com \geq 0\).
Specify decay in terms of span
\(\alpha = 2 / (span + 1)\), for \(span \geq 1\).
Specify decay in terms of half-life
\(\alpha = 1 - \exp\left(-\ln(2) / halflife\right)\), for \(halflife > 0\).
If times is specified, the time unit (str or timedelta) over which an observation decays to half its value. Only applicable to mean(), and halflife value will not apply to the other functions.
New in version 1.1.0.
Specify smoothing factor \(\alpha\) directly
\(0 < \alpha \leq 1\).
Minimum number of observations in window required to have a value; otherwise, result is np.nan.
Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings (viewing EWMA as a moving average).
When adjust=True (default), the EW function is calculated using weights \(w_i = (1 - \alpha)^i\). For example, the EW moving average of the series [\(x_0, x_1, ..., x_t\)] would be:
When adjust=False, the exponentially weighted function is calculated recursively:
Ignore missing values when calculating weights.
When ignore_na=False (default), weights are based on absolute positions. For example, the weights of \(x_0\) and \(x_2\) used in calculating the final weighted average of [\(x_0\), None, \(x_2\)] are \((1-\alpha)^2\) and \(1\) if adjust=True, and \((1-\alpha)^2\) and \(\alpha\) if adjust=False.
When ignore_na=True, weights are based on relative positions. For example, the weights of \(x_0\) and \(x_2\) used in calculating the final weighted average of [\(x_0\), None, \(x_2\)] are \(1-\alpha\) and \(1\) if adjust=True, and \(1-\alpha\) and \(\alpha\) if adjust=False.
If 0 or 'index', calculate across the rows.
If 1 or 'columns', calculate across the columns.
New in version 1.1.0.
Only applicable to mean().
Times corresponding to the observations. Must be monotonically increasing and datetime64[ns] dtype.
If 1-D array like, a sequence with the same shape as the observations.
Deprecated since version 1.4.0: If str, the name of the column in the DataFrame representing the times.
New in version 1.4.0.
Execute the rolling operation per single column or row ('single') or over the entire object ('table').
This argument is only implemented when specifying engine='numba' in the method call.
Only applicable to mean()
See also
Provides rolling window calculations.
Provides expanding transformations.
Notes
See Windowing Operations for further usage details and examples.
Examples
adjust
ignore_na
times
Exponentially weighted mean with weights calculated with a timedelta halflife relative to times.


Provide expanding window calculations.
Minimum number of observations in window required to have a value; otherwise, result is np.nan.
If False, set the window labels as the right edge of the window index.
If True, set the window labels as the center of the window index.
Deprecated since version 1.1.0.
If 0 or 'index', roll across the rows.
If 1 or 'columns', roll across the columns.
Execute the rolling operation per single column or row ('single') or over the entire object ('table').
This argument is only implemented when specifying engine='numba' in the method call.
New in version 1.3.0.
See also
Provides rolling window calculations.
Provides exponential weighted functions.
Notes
See Windowing Operations for further usage details and examples.
Examples
min_periods
Expanding sum with 1 vs 3 observations needed to calculate a value.


Transform each element of a list-like to a row, replicating index values.
New in version 0.25.0.
Column(s) to explode. For multiple columns, specify a non-empty list with each element be str or tuple, and all specified columns their list-like data on same row of the frame must have matching length.
New in version 1.3.0: Multi-column explode
If True, the resulting index will be labeled 0, 1, …, n - 1.
New in version 1.1.0.
Exploded lists to rows of the subset columns; index will be duplicated for these rows.
If columns of the frame are not unique.
If specified columns to explode is empty list.
If specified columns to explode have not matching count of elements rowwise in the frame.
See also
Pivot a level of the (necessarily hierarchical) index labels.
Unpivot a DataFrame from wide format to long format.
Explode a DataFrame from list-like columns to long format.
Notes
This routine will explode list-likes including lists, tuples, sets, Series, and np.ndarray. The result dtype of the subset rows will be object. Scalars will be returned unchanged, and empty list-likes will result in a np.nan for that row. In addition, the ordering of rows in the output will be non-deterministic when exploding sets.
Examples
Single-column explode.
Multi-column explode.


Synonym for DataFrame.fillna() with method='ffill'.
Object with missing values filled or None if inplace=True.


Fill NA/NaN values using the specified method.
Value to use to fill holes (e.g. 0), alternately a dict/Series/DataFrame of values specifying which value to use for each index (for a Series) or column (for a DataFrame). Values not in the dict/Series/DataFrame will not be filled. This value cannot be a list.
Method to use for filling holes in reindexed Series pad / ffill: propagate last valid observation forward to next valid backfill / bfill: use next valid observation to fill gap.
Axis along which to fill missing values.
If True, fill in-place. Note: this will modify any other views on this object (e.g., a no-copy slice for a column in a DataFrame).
If method is specified, this is the maximum number of consecutive NaN values to forward/backward fill. In other words, if there is a gap with more than this number of consecutive NaNs, it will only be partially filled. If method is not specified, this is the maximum number of entries along the entire axis where NaNs will be filled. Must be greater than 0 if not None.
A dict of item->dtype of what to downcast if possible, or the string ‘infer’ which will try to downcast to an appropriate equal type (e.g. float64 to int64 if possible).
Object with missing values filled or None if inplace=True.
See also
Fill NaN values using interpolation.
Conform object to new index.
Convert TimeSeries to specified frequency.
Examples
Replace all NaN elements with 0s.
We can also propagate non-null values forward or backward.
Replace all NaN elements in column ‘A’, ‘B’, ‘C’, and ‘D’, with 0, 1, 2, and 3 respectively.
Only replace the first NaN element.
When filling using a DataFrame, replacement happens along the same column names and same indices
Note that column D is not affected since it is not present in df2.


Subset the dataframe rows or columns according to the specified index labels.
Note that this routine does not filter a dataframe on its contents. The filter is applied to the labels of the index.
Keep labels from axis which are in items.
Keep labels from axis for which “like in label == True”.
Keep labels from axis for which re.search(regex, label) == True.
The axis to filter on, expressed either as an index (int) or axis name (str). By default this is the info axis, ‘index’ for Series, ‘columns’ for DataFrame.
See also
Access a group of rows and columns by label(s) or a boolean array.
Notes
The items, like, and regex parameters are enforced to be mutually exclusive.
axis defaults to the info axis that is used when indexing with [].
Examples


Select initial periods of time series data based on a date offset.
When having a DataFrame with dates as index, this function can select the first few rows based on a date offset.
The offset length of the data that will be selected. For instance, ‘1M’ will display all the rows having their index within the first month.
A subset of the caller.
If the index is not a DatetimeIndex
See also
Select final periods of time series based on a date offset.
Select values at a particular time of the day.
Select values between particular times of the day.
Examples
Get the rows for the first 3 days:
Notice the data for 3 first calendar days were returned, not the first 3 days observed in the dataset, and therefore data for 2018-04-13 was not returned.


Return index for first non-NA value or None, if no NA value is found.
Notes
If all elements are non-NA/null, returns None. Also returns None for empty Series/DataFrame.


Get the properties associated with this pandas object.
The available flags are
Flags.allows_duplicate_labels
See also
Flags that apply to pandas objects.
Global metadata applying to this dataset.
Notes
“Flags” differ from “metadata”. Flags reflect properties of the pandas object (the Series or DataFrame). Metadata refer to properties of the dataset, and should be stored in DataFrame.attrs.
Examples
Flags can be get or set using .
Or by slicing with a key


Get Integer division of dataframe and other, element-wise (binary operator floordiv).
Equivalent to dataframe // other, but with support to substitute a fill_value for missing data in one of the inputs. With reverse version, rfloordiv.
Among flexible wrappers (add, sub, mul, div, mod, pow) to arithmetic operators: +, -, *, /, //, %, **.
Any single or multiple element data structure, or list-like object.
Whether to compare by the index (0 or ‘index’) or columns (1 or ‘columns’). For Series input, axis to match Series index on.
Broadcast across a level, matching Index values on the passed MultiIndex level.
Fill existing missing (NaN) values, and any new element needed for successful DataFrame alignment, with this value before computation. If data in both corresponding DataFrame locations is missing the result will be missing.
Result of the arithmetic operation.
See also
Add DataFrames.
Subtract DataFrames.
Multiply DataFrames.
Divide DataFrames (float division).
Divide DataFrames (float division).
Divide DataFrames (integer division).
Calculate modulo (remainder after division).
Calculate exponential power.
Notes
Mismatched indices will be unioned together.
Examples
Add a scalar with operator version which return the same results.
Divide by constant with reverse version.
Subtract a list and Series by axis with operator version.
Multiply a DataFrame of different shape with operator version.
Divide by a MultiIndex by level.


Construct DataFrame from dict of array-like or dicts.
Creates DataFrame object from dictionary by columns or by index allowing dtype specification.
Of the form {field : array-like} or {field : dict}.
The “orientation” of the data. If the keys of the passed dict should be the columns of the resulting DataFrame, pass ‘columns’ (default). Otherwise if the keys should be rows, pass ‘index’. If ‘tight’, assume a dict with keys [‘index’, ‘columns’, ‘data’, ‘index_names’, ‘column_names’].
New in version 1.4.0: ‘tight’ as an allowed value for the orient argument
Data type to force, otherwise infer.
Column labels to use when orient='index'. Raises a ValueError if used with orient='columns' or orient='tight'.
See also
DataFrame from structured ndarray, sequence of tuples or dicts, or DataFrame.
DataFrame object creation using constructor.
Convert the DataFrame to a dictionary.
Examples
By default the keys of the dict become the DataFrame columns:
Specify orient='index' to create the DataFrame using dictionary keys as rows:
When using the ‘index’ orientation, the column names can be specified manually:
Specify orient='tight' to create the DataFrame using a ‘tight’ format:


Convert structured or record ndarray to DataFrame.
Creates a DataFrame object from a structured ndarray, sequence of tuples or dicts, or DataFrame.
Structured input data.
Field of array to use as the index, alternately a specific set of input labels to use.
Columns or fields to exclude.
Column names to use. If the passed data do not have names associated with them, this argument provides names for the columns. Otherwise this argument indicates the order of the columns in the result (any names not found in the data will become all-NA columns).
Attempt to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point, useful for SQL result sets.
Number of rows to read if data is an iterator.
See also
DataFrame from dict of array-like or dicts.
DataFrame object creation using constructor.
Examples
Data can be provided as a structured ndarray:
Data can be provided as a list of dicts:
Data can be provided as a list of tuples with corresponding columns:


Get Greater than or equal to of dataframe and other, element-wise (binary operator ge).
Among flexible wrappers (eq, ne, le, lt, ge, gt) to comparison operators.
Equivalent to ==, !=, <=, <, >=, > with support to choose axis (rows or columns) and level for comparison.
Any single or multiple element data structure, or list-like object.
Whether to compare by the index (0 or ‘index’) or columns (1 or ‘columns’).
Broadcast across a level, matching Index values on the passed MultiIndex level.
Result of the comparison.
See also
Compare DataFrames for equality elementwise.
Compare DataFrames for inequality elementwise.
Compare DataFrames for less than inequality or equality elementwise.
Compare DataFrames for strictly less than inequality elementwise.
Compare DataFrames for greater than inequality or equality elementwise.
Compare DataFrames for strictly greater than inequality elementwise.
Notes
Mismatched indices will be unioned together. NaN values are considered different (i.e. NaN != NaN).
Examples
Comparison with a scalar, using either the operator or method:
When other is a Series, the columns of a DataFrame are aligned with the index of other and broadcast:
Use the method to control the broadcast axis:
When comparing to an arbitrary sequence, the number of columns must match the number elements in other:
Use the method to control the axis:
Compare to a DataFrame of different shape.
Compare to a MultiIndex by level.


Get item from object for given key (ex: DataFrame column).
Returns default value if not found.
Examples
If the key isn’t found, the default value will be used.


Group DataFrame using a mapper or by a Series of columns.
A groupby operation involves some combination of splitting the object, applying a function, and combining the results. This can be used to group large amounts of data and compute operations on these groups.
Used to determine the groups for the groupby. If by is a function, it’s called on each value of the object’s index. If a dict or Series is passed, the Series or dict VALUES will be used to determine the groups (the Series’ values are first aligned; see .align() method). If a list or ndarray of length equal to the selected axis is passed (see the groupby user guide), the values are used as-is to determine the groups. A label or list of labels may be passed to group by the columns in self. Notice that a tuple is interpreted as a (single) key.
Split along rows (0) or columns (1).
If the axis is a MultiIndex (hierarchical), group by a particular level or levels.
For aggregated output, return object with group labels as the index. Only relevant for DataFrame input. as_index=False is effectively “SQL-style” grouped output.
Sort group keys. Get better performance by turning this off. Note this does not influence the order of observations within each group. Groupby preserves the order of rows within each group.
When calling apply, add group keys to index to identify pieces.
Reduce the dimensionality of the return type if possible, otherwise return a consistent type.
Deprecated since version 1.1.0.
This only applies if any of the groupers are Categoricals. If True: only show observed values for categorical groupers. If False: show all values for categorical groupers.
If True, and if group keys contain NA values, NA values together with row/column will be dropped. If False, NA values will also be treated as the key in groups.
New in version 1.1.0.
Returns a groupby object that contains information about the groups.
See also
Convenience method for frequency conversion and resampling of time series.
Notes
See the user guide for more detailed usage and examples, including splitting an object into groups, iterating through groups, selecting a group, aggregation, and more.
Examples
Hierarchical Indexes
We can groupby different levels of a hierarchical index using the level parameter:
We can also choose to include NA in group keys or not by setting dropna parameter, the default setting is True.


Get Greater than of dataframe and other, element-wise (binary operator gt).
Among flexible wrappers (eq, ne, le, lt, ge, gt) to comparison operators.
Equivalent to ==, !=, <=, <, >=, > with support to choose axis (rows or columns) and level for comparison.
Any single or multiple element data structure, or list-like object.
Whether to compare by the index (0 or ‘index’) or columns (1 or ‘columns’).
Broadcast across a level, matching Index values on the passed MultiIndex level.
Result of the comparison.
See also
Compare DataFrames for equality elementwise.
Compare DataFrames for inequality elementwise.
Compare DataFrames for less than inequality or equality elementwise.
Compare DataFrames for strictly less than inequality elementwise.
Compare DataFrames for greater than inequality or equality elementwise.
Compare DataFrames for strictly greater than inequality elementwise.
Notes
Mismatched indices will be unioned together. NaN values are considered different (i.e. NaN != NaN).
Examples
Comparison with a scalar, using either the operator or method:
When other is a Series, the columns of a DataFrame are aligned with the index of other and broadcast:
Use the method to control the broadcast axis:
When comparing to an arbitrary sequence, the number of columns must match the number elements in other:
Use the method to control the axis:
Compare to a DataFrame of different shape.
Compare to a MultiIndex by level.


Return the first n rows.
This function returns the first n rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it.
For negative values of n, this function returns all rows except the last n rows, equivalent to df[:-n].
Number of rows to select.
The first n rows of the caller object.
See also
Returns the last n rows.
Examples
Viewing the first 5 lines
Viewing the first n lines (three in this case)
For negative values of n


Make a histogram of the DataFrame’s columns.
A histogram is a representation of the distribution of data. This function calls matplotlib.pyplot.hist(), on each series in the DataFrame, resulting in one histogram per column.
The pandas object holding the data.
If passed, will be used to limit data to a subset of columns.
If passed, then used to form histograms for separate groups.
Whether to show axis grid lines.
If specified changes the x-axis label size.
Rotation of x axis labels. For example, a value of 90 displays the x labels rotated 90 degrees clockwise.
If specified changes the y-axis label size.
Rotation of y axis labels. For example, a value of 90 displays the y labels rotated 90 degrees clockwise.
The axes to plot the histogram on.
In case subplots=True, share x axis and set some x axis labels to invisible; defaults to True if ax is None otherwise False if an ax is passed in. Note that passing in both an ax and sharex=True will alter all x axis labels for all subplots in a figure.
In case subplots=True, share y axis and set some y axis labels to invisible.
The size in inches of the figure to create. Uses the value in matplotlib.rcParams by default.
Tuple of (rows, columns) for the layout of the histograms.
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.
All other plotting keyword arguments to be passed to matplotlib.pyplot.hist().
See also
Plot a histogram using matplotlib.
Examples
This example draws a histogram based on the length and width of some animals, displayed in three bins


Access a single value for a row/column pair by integer position.
Similar to iloc, in that both provide integer-based lookups. Use iat if you only need to get or set a single value in a DataFrame or Series.
When integer position is out of bounds.
See also
Access a single value for a row/column label pair.
Access a group of rows and columns by label(s).
Access a group of rows and columns by integer position(s).
Examples
Get value at specified row/column pair
Set value at specified row/column pair
Get value within a series


Return index of first occurrence of maximum 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 maxima along the specified axis.
If the row/column is empty
See also
Return index of the maximum element.
Notes
This method is the DataFrame version of ndarray.argmax.
Examples
Consider a dataset containing food consumption in Argentina.
By default, it returns the index for the maximum value in each column.
To return the index for the maximum value in each row, use axis="columns".