Pandas Tutorial Pandas References

Pandas - DataFrame Functions



The Pandas DataFrame has a number of built-in functions that are always available for use. For example, sum() function is used to get the sum of all values over the specified axis. The most frequently used functions of pandas dataframe are listed below:

Pandas - DataFrame Functions

Indexing / Iteration

FunctionDescription
iat[] Access a single value for a row/column pair by integer position.
head() Returns the first specified number of rows.
iloc[] Purely integer-location based indexing for selection by position.
items() Iterate over (column name, Series) pairs.
iteritems() Iterate over (column name, Series) pairs.
iterrows() Iterate over DataFrame rows as (index, Series) pairs.
itertuples() Iterate over DataFrame rows as namedtuples.
pop() Returns item and drop from frame.
tail() Returns the last specified number of rows.

Binary Operators

FunctionDescription
add() Returns addition of dataframe and argument, element-wise.
sub() Returns subtraction of dataframe and argument, element-wise.
mul() Returns multiplication of dataframe and argument, element-wise.
div() Returns floating division of dataframe and argument, element-wise.
truediv() Returns floating division of dataframe and argument, element-wise.
floordiv() Returns integer division of dataframe and argument, element-wise.
mod() Returns modulo of dataframe and argument, element-wise.
pow() Returns exponential power of dataframe and argument, element-wise.
lt() Get less than of dataframe and argument, element-wise.
gt() Get greater than of dataframe and argument, element-wise.
le() Get less than equal to of dataframe and argument, element-wise.
ge() Get greater than equal to of dataframe and argument, element-wise.
eq() Get equal to of dataframe and argument, element-wise.
ne() Get Not equal to of dataframe and argument, element-wise.

Computation / Descriptive stats

FunctionDescription
abs() Returns a Series/DataFrame with absolute numeric value of each element.
clip() Trim values at input threshold(s).
corr() Computes pairwise correlation of columns, excluding NA/null values.
count() Returns the count of non-NA cells for each column or row.
cov() Computes pairwise covariance of columns, excluding NA/null values.
cummax() Return cumulative maximum over a DataFrame or Series axis.
cummin() Return cumulative minimum over a DataFrame or Series axis.
cumprod() Return cumulative product over a DataFrame or Series axis.
cumsum() Return cumulative sum over a DataFrame or Series axis.
diff() Returns first discrete difference of element.
kurt() Returns unbiased kurtosis over the specified axis.
kurtosis() Returns unbiased kurtosis over the specified axis.
max() Returns the maximum of the values over the specified axis.
mean() Returns the mean of the values over the specified axis.
median() Returns the median of the values over the specified axis.
min() Returns the minimum of the values over the specified axis.
mode() Returns the mode(s) of each element over the specified axis.
pct_change() Returns percentage change between the current and a prior element.
nunique() Count distinct observations over requested axis.
prod() Returns the product of the values over the specified axis.
product() Returns the product of the values over the specified axis.
rank() Computes numerical data ranks (1 through n) along axis.
round() Rounds a DataFrame to a specified number of decimal places.
skew() Returns unbiased skew over the specified axis.
std() Returns the sample standard deviation over the specified axis.
sum() Returns the sum of the values over the specified axis.
value_counts() Returns a Series containing counts of unique rows in the DataFrame.
var() Returns unbiased variance over the specified axis.

Reindexing / Selection / Label manipulation

FunctionDescription
drop_duplicates() Returns DataFrame with duplicate rows removed.

Combining / Comparing / Joining / Merging

FunctionDescription
append() Append rows of other to the end of caller, returning a new object.

Function application, GroupBy & window

FunctionDescription
agg() Aggregate using one or more operations over the specified axis.
aggregate() Aggregate using one or more operations over the specified axis.
expanding() Provide expanding transformations.
transform() Call func on self producing a DataFrame with transformed values.

Time Series-related

FunctionDescription
shift() Shift index by specified number of periods with an optional time freq.

Missing data handling

FunctionDescription
fillna() Fill NA/NaN values using the specified method.

Plotting

FunctionDescription
plot.area() Makes a stacked area plot.
plot.bar() Makes a vertical bar plot.
plot.barh() Makes a horizontal bar plot.
plot.box() Makes a box plot of the DataFrame columns.
plot.hist() Draws histogram of the DataFrame columns.
plot.line() Plots Series or DataFrame as lines.
plot.pie() Generates a pie plot.