Pandas
keyboard_arrow_down 655 guides
chevron_leftPandas
Common questions10 topics
Documentation5 topics
Cookbooks2 topics
Getting startedAPI referenceRecipes referencecheck_circle
Mark as learned thumb_up
1
thumb_down
0
chat_bubble_outline
0
Comment auto_stories Bi-column layout
settings
Pandas | API reference
schedule Aug 12, 2023
Last updated local_offer
Tags Python●Pandas
tocTable of Contents
expand_more SeriesString OperationsGeneral FunctionsDataFrameBasic and Descriptive StatisticsBinary OperatorsCombining DataFramesData Indexing and MasksData Selection and RenamingFunctions and AggregationsHandling Missing ValuesIteratorsMeta InformationMiscellaneousPropertiesSorting and Restructuring DataFramesTime SeriesType ConversionDatetimes
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!
Start your free 7-days trial now!
Series
- Pandas | Series constructorPandas Series(~) constructor initialises a new Series.
- Pandas Series | argmax methodPandas Series.argmax(~) returns the integer index of the maximum value in the Series. If there are multiple maximums, then the integer index of the first occurrence will be returned.
- Pandas Series | argmin methodPandas Series.argmin(~) returns the integer index of the minimum value in the Series. If there are multiple minimums, then the integer index of the first occurrence will be returned.
- Pandas Series | between methodPandas Series.between(~) method returns a vector of booleans indicating whether each element in the Series is within the provided range. NaN values are considered as False.
- Pandas Series | map methodPandas Series.map(~) method applies a mapping to each value of the Series. The mapping is not applied inplace, that is, a new Series is returned.
- Pandas Series | to_frame methodConverts a Series to a single-column DataFrame.
- Pandas Series | to_list methodPandas Series.to_list(~) method converts the Series into a Python's standard list.
- Pandas Series | value_counts methodPandas Series.value_counts(~) method returns the count of unique values in the Series.
- Pandas Series | hasnans propertyPandas Series.hasnans property returns True if the Series contains a missing value (NaN), and False otherwise.
- Pandas Series | is_monotonic propertyPandas Series.is_monotonic property returns True if the values in the Series are monotonically increasing, and False otherwise.
- Pandas Series | is_monotonic_decreasing propertyPandas Series.is_monotonic_decreasing property returns True if the values in the Series are monotonically decreasing, and False otherwise.
- Pandas Series | is_monotonic_increasing propertyPandas Series.is_monotonic_increasing property returns True if the values in the Series are monotonically increasing, and False otherwise.
- Pandas Series | is_unique propertyPandas Series.is_unique property returns True if all the values in the Series are unique, otherwise False is returned.
String Operations
- Pandas Series str | extract methodPandas Series str.extract(~) extracts the first matched substrings using regular expression.
- Pandas Series str | extractall methodPandas Series' str.extractall(~) extracts all the matched substrings using regular expression.
- Pandas Series str | center methodPandas Series.str.center(~) pads the left and right side of each string in the Series until the specified width is reached. If the length of the string is larger than the specified width, then the string is left as is.
- Pandas Series string | contains methodPandas Series str.contains(~) method checks whether or not each value of the source Series contains the specified substring or regex pattern.
- Pandas Series str | len methodPandas Series str.len(~) method returns the length of each string in the Series.
- Pandas Series str | lower methodPython's str.lower() method converts all strings in a Series/Index to lowercase.
- Pandas Series str | lstrip methodPandas Series str.lstrip(~) method removes the combination of the specified characters that appear from the left of each string in the Series. Note that a new Series is returned, and the original is kept intact.
- Pandas Series str | pad methodPandas Series.pad(~) pads each string of the Series until the specified length is reached.
- Pandas Series str | replace methodPandas Series str.replace(~) method replaces a substring of each string in the Series with a specified value.
- Pandas Series str | rstrip methodPandas Series str.rstrip(~) method removes the combination of the specified characters that appear from the right of each string in the Series. Note that a new Series is returned, and the original is kept intact.
- Pandas Series str | split methodPandas Series.str.split(~) method performs a split on each string in the Series.
- Pandas Series str | strip methodPandas Series str.strip(~) method removes the combination of the specified characters that appear in the front and back of each string in the Series.
- Pandas Series | zfill methodPandas Series.str.zfill(~) method left-fills each string of the Series with zeros until the specified width is reached.
- Pandas Series str | extract method
General Functions
- Pandas | bdate_range methodPandas bdate_range(~) method returns a DatetimeIndex containing the specified business days.
- Pandas | concat methodPandas concat(~) method concatenates a list of Series or DataFrame, either horizontally or vertically.
- Pandas | crosstab methodPandas crosstab(~) method computes the cross tabulation of multiple column variables. By default, the computed statistic is the count.
- Pandas | cut methodPandas cut(~) method categorises numerical values into bins (intervals).
- Pandas | date_range methodPandas date_range(~) method returns a DatetimeIndex with fixed frequency.
- Pandas | factorize methodPandas factorize(~) method returns an array of integer indices to map the input array to the unique values, and all the unique values of the input array.
- Pandas | get_dummies methodPandas get_dummies(~) method performs one-hot encoding or dummy coding on categorical variables.
- Pandas | infer_freq methodPandas infer_freq(~) method returns a string indicating the inferred frequency of the given DatetimeIndex or a TimedeltaIndex.
- Pandas | interval_range methodPandas interval_range(~) method returns an IntervalIndex with fixed frequency.
- Pandas | isnull methodPandas isnull(~) method returns a boolean mask where True is set for NaNs (missing values) and False for non-NaNs.
- Python | merge_asof methodPandas merge_asof(~) method is used to perform a left join on two DataFrames where the join keys are matched not by equality but by proximity.
- Pandas | merge_ordered methodPandas merge_ordered(~) method joins two DataFrames with the option to perform filling or interpolation.
- Pandas | notnull methodPandas notnull(~) method returns a boolean mask where True is set for non-NaN values and False for NaNs.
- Pandas | period_range methodPandas period_range(~) method returns a PeriodIndex with fixed frequency. A Period represents a specific time span or a duration.
- Pandas | pivot methodPandas pivot(~) method converts the input DataFrame into a pivot table.
- Pandas | pivot_table methodPandas pivot_table(~) method converts the input DataFrame into a pivot table.
- Pandas | qcut methodPandas qcut(~) method categorises numerical values into quantile bins (intervals).
- Pandas | read_csv methodPandas read_csv(~) method reads a file, and parses its content into a DataFrame.
- Pandas | to_datetime methodPandas to_datetime(~) method converts the argument into a datetime object.
- Pandas | to_numeric methodPandas to_numeric(~) method converts the input to a numerical type. By default, either int64 or float64 will be used.
- Pandas | to_timedelta methodPandas to_timedelta(~) method converts the given argument into timedeltas.
- Pandas | unique methodPandas unique(~) method returns the unique values of the input array. The order of the returned values follow their original order in the input array.
- Pandas DataFrame | wide_to_long methodPandas wide_to_long(~) method converts the format of a DataFrame from wide to long.
DataFrame
- Pandas | DataFrame constructorPandas DataFrame(~) constructor is used to initialise a new DataFrame.
Basic and Descriptive Statistics
- Pandas DataFrame | abs methodPandas DataFrame.abs() method returns a DataFrame with the absolute value applied to each of its values.
- Pandas DataFrame | clip methodPandas DataFrame.clip(~) method is used to ensure that the values of the DataFrame are between a particular range.
- Pandas DataFrame | corr methodPandas DataFrame.corr(~) method computes pair-wise correlation of the columns in the source DataFrame.
- Pandas DataFrame | corrwith methodPandas DataFrame.corrwith(~) computes the pairwise correlation between the columns or rows of the source DataFrame and the given Series or DataFrame.
- Pandas DataFrame | count methodPandas DataFrame.count(~) method counts the number of non-missing values for each row or column of the DataFrame.
- Pandas DataFrame | cov methodPandas DataFrame.cov(~) method computes the covariance matrix of the columns in the source DataFrame.
- Pandas DataFrame | cummax methodPandas DataFrame.cummax(~) method computes the cumulative maximum along the row or column of the source DataFrame.
- Pandas DataFrame | cummin methodPandas DataFrame.cummin(~) method computes the cumulative minimum along the row or column of the source DataFrame.
- Pandas DataFrame | cumprod methodPandas DataFrame.cumprod(~) method computes the cumulative product along the row or column of the source DataFrame.
- Pandas DataFrame | cumsum methodPandas DataFrame.cumsum(~) method computes the cumulative sum along the row or column of the source DataFrame.
- Pandas DataFrame | describe methodPandas DataFrame.describe(~) method returns a DataFrame containing some descriptive statistics (e.g. mean and min) of the columns of the source DataFrame. This is most commonly used to numerically summarise a given dataset.
- Pandas DataFrame | diff methodPandas DataFrame.diff(~) method returns a new DataFrame where each value represents the difference between the value and the value of the previous row or column.
- Pandas DataFrame | eval methodPandas DataFrame.eval(~) method evaluates an operation, which is encoded as a string, on the DataFrame's columns.
- Pandas DataFrame | mad methodPandas DataFrame.mad(~) method computes the mean absolute deviation (MAD) for each row or column of the DataFrame.
- Pandas DataFrame | max methodPandas DataFrame.max(~) method computes the maximum of each column or row of the DataFrame.
- Pandas DataFrame | mean methodPandas DataFrame.mean(~) method computes the mean for each row or column of the DataFrame.
- Pandas DataFrame | median methodPandas DataFrame.median(~) method computes the median for each row or column of the DataFrame.
- Pandas DataFrame | min methodPandas DataFrame.min(~) method computes the minimum of each row or column of the DataFrame.
- Pandas DataFrame | mode methodPandas DataFrame.mode(~) method computes the mode of each column or row of the DataFrame. If the counts of some values are the same, then all their modes will be returned.
- Pandas DataFrame | nunique methodPandas DataFrame.nunique(~) method counts the number of unique values for each row or column.
- Pandas DataFrame | pct_change methodPandas DataFrame.pct_change(~) computes the percentage change between consecutive values of each column of the DataFrame.
- Pandas DataFrame | product methodPandas DataFrame.product(~) method computes the product for each row or column of the DataFrame.
- Pandas DataFrame | quantile methodPandas DataFrame.quantile(~) method returns the interpolated value at the specified quantile.
- Pandas DataFrame | rank methodPandas DataFrame.rank(~) method computes the ordering of the values for each row or column of the DataFrame.
- Pandas DataFrame | round methodPandas DataFrame.round(~) method returns a DataFrame with all its numerical values rounded according to the specified parameters.
- Pandas DataFrame | sem methodPandas DataFrame.sem(~) method returns the unbiased standard error of the mean for each row or column of the source DataFrame.
- Pandas DataFrame | std methodPandas DataFrame.std(~) method computes the standard deviation of each row or column of the source DataFrame.
- Pandas DataFrame | sum methodPandas DataFrame.sum(~) method computes the sum for each row or column of the source DataFrame.
- Pandas DataFrame | var methodPandas DataFrame.var(~) method computes the variance of each row or column of the source DataFrame.
- Pandas DataFrame | abs method
Binary Operators
- Pandas DataFrame | add methodPandas DataFrame.add(~) method computes the sum of the values in the source DataFrame and another scalar, sequence Series or DataFrame.
- Pandas DataFrame | combine methodPandas DataFrame.combine(~) method combines the columns of two DataFrames. Note that only columns that share the same column label will be combined.
- Pandas DataFrame | combine_first methodPandas DataFrame.combine_first(~) method replaces all instances of missing values (NaN) in one DataFrame with non-missing values from the other DataFrame.
- Pandas DataFrame | div methodPandas DataFrame.div(~) method divides the values in the source DataFrame by a scalar, sequence, Series or DataFrame.
- Pandas DataFrame | dot methodPandas DataFrame.dot(~) method is used to compute matrix-vector and matrix-matrix multiplication.
- Pandas DataFrame | eq methodPandas DataFrame.eq(~) method returns a DataFrame of booleans where True indicates an entry that is equal to the specified value.
- Pandas DataFrame | floordiv methodPandas DataFrame.floordiv(~) method divides the values in the source DataFrame by a scalar, sequence, Series or DataFrame via integer division.
- Pandas DataFrame | ge methodPandas DataFrame.ge(~) method returns a DataFrame of booleans where True indicates an entry that is greater than or equal to the specified value.
- Pandas DataFrame | gt methodPandas DataFrame.gt(~) method returns a DataFrame of booleans where True indicates an entry that is strictly greater than the specified value.
- Pandas DataFrame | le methodPandas DataFrame.le(~) method returns a DataFrame of booleans where True indicates an entry that is less than or equal to the specified value.
- Pandas DataFrame | lt methodPandas DataFrame.lt(~) method returns a DataFrame of booleans where True indicates an entry that is strictly less than the specified value.
- Pandas DataFrame | mod methodPandas DataFrame.mod(~) method computes the modulo of the values in the source DataFrame and another scalar, sequence, Series or DataFrame.
- Pandas DataFrame | mul methodPandas DataFrame.mul(~) method multiplies the values in the source DataFrame to a scalar, sequence, Series or DataFrame.
- Pandas DataFrame | ne methodPandas DataFrame.ne(~) method returns a DataFrame of booleans where True indicates an entry that is not equal (!=) to the specified value.
- Pandas DataFrame | pow methodPandas DataFrame.pow(~) method computes the exponential power of the values in the source DataFrame and another scalar, sequence, Series or DataFrame.
- Pandas DataFrame | radd methodPandas DataFrame.radd(~) method computes and returns the sum of a scalar, sequence, Series or DataFrame and the values in the source DataFrame.
- Pandas DataFrame | rdiv methodPandas DataFrame.rdiv(~) method divides a scalar, sequence, Series or DataFrame by the values in the source DataFrame.
- Pandas DataFrame | rfloordiv methodPandas DataFrame.rfloordiv(~) method performs integer division between a scalar, sequence, Series or DataFrame and the values in the source DataFrame.
- Pandas DataFrame | rmod methodPandas DataFrame.rmod(~) method computes the modulo of the values in the source DataFrame and another scalar, sequence, Series or DataFrame.
- Pandas DataFrame | rmul methodPandas DataFrame.rmul(~) method multiplies a scalar, sequence, Series or DataFrame to the values in the source DataFrame.
- Pandas DataFrame | rpow methodPandas DataFrame.rpow(~) method computes the exponential power of a scalar, sequence, Series or DataFrame and the values in the source DataFrame.
- Pandas DataFrame | rsub methodPandas DataFrame.rsub(~) method subtracts the values in the source DataFrame from a scalar, sequence, Series or DataFrame.
- Pandas DataFrame | rtruediv methodPandas DataFrame.rtruediv(~) method divides a scalar, sequence, Series or DataFrame by the values in the source DataFrame.
- Pandas DataFrame | sub methodPandas DataFrame.sub(~) method subtracts a scalar, sequence, Series or DataFrame from the values in the source DataFrame.
- Pandas DataFrame | truediv methodPandas DataFrame.truediv(~) method divides the values in the source DataFrame by a scalar, sequence, Series or DataFrame.
- Pandas DataFrame | add method
Combining DataFrames
- Pandas DataFrame | append methodPandas DataFrame.append(~) method appends new rows to the source DataFrame.
- Pandas DataFrame | assign methodPandas DataFrame.assign(~) method appends a new column to the DataFrame.
- Pandas DataFrame | insert methodPandas DataFrame.insert(~) method inserts a new column into the source DataFrame.
- Pandas DataFrame | join methodPandas DataFrame.join(~) merges the source DataFrame with other Series or DataFrames.
- Pandas DataFrame | merge methodPandas DataFrame.merge(~) method merges the source DataFrame with another DataFrame or a named Series.
- Pandas DataFrame | pop methodPandas DataFrame.pop(~) method removes a single column of a DataFrame.
- Pandas DataFrame | update methodPandas DataFrame.update(~) method replaces the values in the source DataFrame using non-NaN values from another DataFrame.
- Pandas DataFrame | append method
Data Indexing and Masks
- Pandas DataFrame | all methodPandas DataFrame.all(~) method checks each row or column, and returns True for that row/column if all its values evaluate to True.
- Pandas DataFrame | any methodPandas any(~) method scans through each row or column of the DataFrame, and if the row/column contains at least one non-zero value or a boolean True, then True is returned for that row/column.
- Pandas DataFrame | isin methodPandas's DataFrame.isin(~) method checks if certain values are present in the DataFrame.
- Pandas DataFrame | isna methodPandas's DataFrame.isna(~) method returns a boolean mask where True is set for missing values (NaN) and False for non-missing values.
- Pandas DataFrame | isnull methodPandas DataFrame.isnull(~) method returns a boolean mask where True is set for missing values (NaNs) and False for the rest.
- Pandas DataFrame | mask methodPandas's DataFrame.mask(~) replaces all values in the DataFrame that pass a certain criteria with the desired value.
- Pandas DataFrame | notna methodPandas's DataFrame.notna(~) method returns a boolean mask where True is set for non-missing values and False for NaNs.
- Pandas DataFrame | where methodPandas DataFrame.where(~) uses a boolean mask to selectively replace values in the source DataFrame.
- Pandas DataFrame | at propertyPanda's DataFrame.at property is used to access or update a single value in the DataFrame using row/column labels.
- Pandas DataFrame | iat propertyPanda's DataFrame.iat property is used to access or update a single value in the DataFrame using integer syntax.
- Pandas DataFrame | iloc propertyPandas's DataFrame.iloc is used to access and update specific rows/columns of the DataFrame using integer indices.
- Pandas DataFrame | loc propertyPandas DataFrame.loc is used to access and update values of the DataFrame using row and column labels.
- Pandas DataFrame | all method
Data Selection and Renaming
- Pandas DataFrame | add_prefix methodPandas DataFrame.add_prefix(~) prepends the specified string to each column label of the DataFrame.
- Pandas DataFrame | add_suffix methodPandas's DataFrame.add_suffix(~) appends the specified string to each column label of the DataFrame.
- Pandas DataFrame | align methodPandas DataFrame.align(~) method ensures that two DataFrames have the same column or row labels.
- Pandas DataFrame | at_time methodPandas DataFrame.at_time(~) method extracts rows that are of the specified time of day.
- Pandas DataFrame | between_time methodPandas DataFrame.between_time(~) method returns rows that fall between the specified start time and end time.
- Pandas DataFrame | drop methodPandas's DataFrame.drop(~) method returns a DataFrame with the specified columns/rows removed.
- Pandas DataFrame | drop_duplicates methodPandas's DataFrame.drop_duplicates(~) method returns a DataFrame with duplicate rows removed.
- Pandas DataFrame | duplicated methodPandas DataFrame.duplicated(~) method returns a Series of booleans where True represents duplicate rows.
- Pandas DataFrame | equals methodPandas DataFrame.equals(~) checks whether two DataFrames are identical, that is, all their respective values, column labels and index names are equal, and have the same data type.
- Pandas DataFrame | filter methodPandas DataFrame.filter(~) method returns the rows or columns where the label matches the specified pattern.
- Pandas DataFrame | first methodPandas DataFrame.first(~) method returns all rows that fall in the first n days (or whatever time unit you specify), where n is the specified offset.
- Pandas DataFrame | get methodPandas's DataFrame.get(~) is used to access columns of the DataFrame.
- Pandas DataFrame | head methodPandas DataFrame.head(~) method returns the first n rows of the DataFrame.
- Pandas DataFrame | idxmax methodPandas DataFrame.idxmax(~) method returns the column/row label of the maximum value of each row/column of the source DataFrame.
- Pandas DataFrame | idxmin methodPandas DataFrame.idxmin(~) method returns the column/row label of the minimum value of each row/column of the source DataFrame.
- Pandas DataFrame | last methodPandas DataFrame.last(~) method returns all rows that fall in the last n days (or whatever time unit you specify), where n is the specified offset.
- Pandas DataFrame | lookup methodPandas DataFrame.lookup(~) method extracts individual values from the source DataFrame in a single Numpy Array.
- Pandas DataFrame | query methodPandas's DataFrame.query(~) method filters rows according to the provided boolean expression.
- Pandas DataFrame | reindex methodPandas DataFrame.reindex(~) method sets a new index for the source DataFrame, and places NaN to values whose row or column label is new.
- Pandas DataFrame | rename methodPanda's DataFrame.rename(~) method renames the columns and indexes of the DataFrame.
- Pandas DataFrame | rename_axis methodPandas's DataFrame.rename_axis(~) method modifies the axis labels.
- Pandas DataFrame | reset_index methodPandas's DataFrame.reset_index(~) resets the index to the default integer index.
- Pandas DataFrame | sample methodPandas DataFrame.sample(~) method returns the specified number of rows or columns randomly.
- Pandas DataFrame | select_dtypes methodPandas DataFrame.select_dtypes(~) returns a subset of columns that match (or not match) the specified type.
- Pandas DataFrame | set_axis methodPandas's DataFrame.set_axis(~) method assigns a new label to the source DataFrame's columns or index.
- Pandas DataFrame | set_index methodPandas's DataFrame.set_index(~) sets the index of the DataFrame using one of its columns.
- Pandas DataFrame | tail methodPandas DataFrame.tail(~) method returns the last n rows of the DataFrame.
- Pandas DataFrame | take methodPandas DataFrame.take(~) method returns a new DataFrame containing the specified rows or columns.
- Pandas DataFrame | truncate methodPanda's DataFrame.truncate(~) method extracts a subset of rows from the DataFrame using truncation.
- Pandas DataFrame | add_prefix method
Functions and Aggregations
- Pandas DataFrame | agg methodPandas DataFrame.agg(~) applies the specified function to each row or column of the DataFrame.
- Pandas DataFrame | apply methodPandas DataFrame.apply(~) applies the specified function to each row or column of the DataFrame.
- Pandas DataFrame | applymap methodPandas DataFrame.applymap(~) method applies a function on each entry of the source DataFrame. Note that a new copy of the DataFrame will be returned, and so the source DataFrame will be kept intact.
- Pandas DataFrame | expanding methodPandas DataFrame.expanding(~) method is used to compute cumulative statistics.
- Pandas DataFrame | groupby methodPandas's DataFrame.groupby(~) divides up your DataFrame into groups based on the specified criteria. The returned value is useful because it allows you to compute statistics (e.g. mean and min) and apply transformations group-wise.
- Pandas DataFrame | pipe methodPandas DataFrame.pipe(~) method applies a specified function on the source DataFrame.
- Pandas DataFrame | rolling methodPandas DataFrame.rolling(~) method is used to compute the statistics using moving windows. Note that a window is simply a sequence of values used to compute a statistics like the mean.
- Pandas DataFrame | transform methodPandas DataFrame.transform(~) method applies a function to transform the rows or columns of the source DataFrame.
- Pandas DataFrame | agg method
Handling Missing Values
- Pandas DataFrame | dropna methodPandas's DataFrame.dropna(~) method removes rows or columns with missing values (NaNs).
- Pandas DataFrame | fillna methodPandas DataFrame.fillna(~) method fills missing values (NaNs) with a specified value or with a filling rule.
- Pandas DataFrame | interpolate methodPandas DataFrame.interpolate(~) method fills missing values (NaNs) using interpolated values.
- Pandas DataFrame | replace methodPandas's DataFrame.replace(~) method replaces the specified values with another set of values.
- Pandas DataFrame | dropna method
Iterators
- Pandas DataFrame | __iter__ methodPandas DataFrame.__iter__() method returns an iterator over the column labels.
- Pandas DataFrame | items methodPandas's DataFrame.items() method is used to iterate over all pairs of column name (string) and column values (Series) in the DataFrame.
- Pandas DataFrame | iteritems methodPandas DataFrame.iteritems() method is used to iterate over the column labels and column data of the source DataFrame.
- Pandas DataFrame | iterrows methodPandas's DataFrame.iterrows() method is used to iterate over all pairs of row name (object) and row values (Series) in the source DataFrame.
- Pandas DataFrame | itertuples methodPanda's DataFrame.itertuples(~) method is used to iterate over the rows of the DataFrame as named tuples.
- Pandas DataFrame | keys methodPandas DataFrame.keys() method returns the columns of the DataFrame as an Index object.
- Pandas DataFrame | __iter__ method
Meta Information
- Pandas DataFrame | info methodPandas DataFrame.info(~) method outputs a brief summary of the DataFrame, which includes information such as the data-types and memory consumption.
- Pandas DataFrame | memory_usage methodPandas DataFrame.memory_usage(~) returns the amount of memory each column occupies in bytes.
- Pandas DataFrame | info method
Miscellaneous
- Pandas DataFrame | bool methodPandas DataFrame.bool() method returns True if a DataFrame of size one holds a True boolean, and False if it holds a False boolean.
- Pandas DataFrame | copy methodPandas DataFrame.copy(~) method makes a copy of a DataFrame. You can choose whether you want a deep copy or a shallow copy.
- Pandas DataFrame | bool method
Properties
- Pandas DataFrame | T propertyPandas DataFrame.T property transposes the rows and columns.
- Pandas DataFrame | axes propertyPandas DataFrame.axes property returns the row and column labels of the DataFrame as a list.
- Pandas DataFrame | columns propertyPanda's DataFrame.columns property returns an Index containing the column names of the DataFrame.
- Pandas DataFrame | dtypes propertyPandas DataFrame.dtypes property returns the data type of the values stored in each column.
- Pandas DataFrame | empty propertyPandas DataFrame.empty property returns True if the DataFrame does not contain any elements.
- Pandas DataFrame | index propertyPanda's DataFrame.index property returns an Index containing the index names of the DataFrame.
- Pandas DataFrame | ndim propertyPandas DataFrame.ndim property returns the number of dimensions of the DataFrame, which is always 2.
- Pandas DataFrame | shape propertyPandas DataFrame.shape property returns the number of rows and columns in the DataFrame as a tuple.
- Pandas DataFrame | size propertyPandas's DataFrame.size property returns the number of values in the DataFrame.
- Pandas DataFrame | values propertyPandas DataFrame.values property returns the values of the DataFrame as a 2D NumPy array.
- Pandas DataFrame | T property
Sorting and Restructuring DataFrames
- Pandas DataFrame | droplevel methodPandas DataFrame.droplevel(~) method returns a new DataFrame with the specified column or index levels removed.
- Pandas DataFrame | explode methodPandas DataFrame.explode(~) method unwraps array-likes such as lists, tuples, Series and Numpy arrays vertically.
- Pandas DataFrame | melt methodPandas DataFrame.melt(~) method converts the format of the source DataFrame from "wide" to "long".
- Pandas DataFrame | nlargest methodPandas DataFrame.nlargest(~) method returns n rows with the largest value in the specified columns.
- Pandas DataFrame | nsmallest methodPandas DataFrame.nsmallest(~) method returns n rows with the smallest value for the specified columns.
- Pandas DataFrame | reorder_levels methodPandas DataFrame.reorder_levels(~) method changes the ordering of levels.
- Pandas DataFrame | sort_index methodPandas's DataFrame.sort_index(~) method sorts the source DataFrame by either column or index labels.
- Pandas DataFrame | sort_values methodPandas DataFrame.sort_values(~) method sorts the source DataFrame either by column or row values.
- Pandas DataFrame | squeeze methodPandas DataFrame.squeeze(~) method reduces a DataFrame with a single row or column to a Series.
- Pandas DataFrame | stack methodPandas DataFrame.stack(~) method converts the specified column levels to row levels.
- Pandas DataFrame | swapaxes methodPandas DataFrame.swapaxes(~) method swaps the rows and the columns of the DataFrame.
- Pandas DataFrame | swaplevel methodPandas DataFrame.swaplevel(~) method swaps two levels of a multi-index DataFrame.
- Pandas DataFrame | transpose methodPandas DataFrame.transpose(~) method swaps the rows and columns of the source DataFrame.
- Pandas DataFrame | unstack methodPandas DataFrame.unstack(~) method converts the specified row levels to column levels.
- Pandas DataFrame | droplevel method
Time Series
- Pandas DataFrame | asfreq methodPandas DataFrame.asfreq(~) method returns a DataFrame with a new time index that respects the specified frequency.
- Pandas DataFrame | asof methodPandas DataFrame.asof(~) method returns the last row that contains no NaN.
- Pandas DataFrame | first_valid_index methodPandas DataFrame.first_valid_index(~) method returns the index of the first occurrence of a row containing a non-NaN value. The check is performed row-wise, starting from the first row.
- Pandas DataFrame | last_valid_index methodPandas DataFrame.last_valid_index(~) method returns the index of the last occurrence of a row containing a non-NaN value. The check is performed row-wise, starting from the first row.
- Pandas DataFrame | resample methodPandas DataFrame.resample(~) method performs a group-by based on time.
- Pandas DataFrame | shift methodPandas DataFrame.shift(~) method shifts the rows or columns by the specified amount, without changing the size of the DataFrame.
- Pandas DataFrame | slice_shift methodPandas DataFrame.slice_shift(~) method shifts the rows of the DataFrame by the specified amount, and empty rows are stripped away.
- Pandas DataFrame | to_period methodPandas DataFrame.to_period(~) method converts the source DataFrame's DatetimeIndex to PeriodIndex.
- Pandas DataFrame | to_timestamp methodPandas DataFrame.to_timestamp(~) method converts the row index or column index to DatetimeIndex.
- Pandas DataFrame | tshift methodPandas DataFrame.tshift(~) method shifts the date index of the source DataFrame.
- Pandas DataFrame | tz_convert methodPandas DataFrame.tz_convert(~) method converts the timezone of the row or column index.
- Pandas DataFrame | tz_localize methodPandas DataFrame.tz_localize(~) method makes the DataFrame's index timezone-aware.
- Pandas DataFrame | asfreq method
Type Conversion
- Pandas DataFrame | astype methodPandas DataFrame.astype(~) method converts the data type of the columns of a DataFrame to the specified type.
- Pandas DataFrame | convert_dtypes methodPandas DataFrame.convert_dtypes(~) method converts the data type of the columns of the source DataFrame to a more suitable/specific one.
- Pandas DataFrame | infer_objects methodPandas DataFrame.infer_objects(~) method converts columns that are of data-type object to a more specific type by inferring from its data.
- Pandas DataFrame | to_csv methodPandas DataFrame.to_csv(~) method converts the source DataFrame into comma-separated value format.
- Pandas DataFrame | to_dict methodPandas DataFrame.to_dict(~) method converts the DataFrame to a Python dictionary or list of dictionaries.
- Pandas DataFrame | to_json methodPandas DataFrame.to_json(~) method either converts a DataFrame to a JSON string, or outputs a JSON file.
- Pandas DataFrame | to_numpy methodPandas DataFrame.to_numpy(~) method returns the values of the DataFrame as a 2D Numpy array.
- Pandas DataFrame | astype method
Datetimes
- Pandas | DatetimeIndex constructorPandas DatetimeIndex constructor creates a new DatetimeIndex object, which is most often used as the index of a DataFrame.
- Pandas | Period constructorPandas Period(~) constructor creates a new Period object, which represents a specific time span or a duration.
- Pandas | PeriodIndex constructorPandas PeriodIndex(~) constructor creates a new PeriodIndex object, which represents a specific time span or a duration. PeriodIndex is most often used as the index of a DataFrame.
- Pandas | Timedelta constructorPandas Timedelta(~) constructor creates a new Timedelta object, which represents a time difference in units that you specify. It is typically used to perform date arithmetics.
- Pandas | Timestamp constructorTimestamp is the Pandas' implementation of Python's Datetime, and their functionality and properties are nearly identical. Timestamp is the underlying data structure used for DatetimeIndex.
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
1
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!