0% found this document useful (0 votes)
4 views3 pages

Pandas Methods Overview

Uploaded by

hpatel63557
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Pandas Methods Overview

Uploaded by

hpatel63557
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Pandas Methods Overview

Data Creation
pd.DataFrame(): Create a DataFrame.
pd.Series(): Create a Series.
pd.read_csv(), pd.read_excel(), pd.read_sql(), pd.read_json(),
pd.read_html(), etc.: Read data from various sources.
pd.concat(), pd.merge(), pd.join(): Combine data structures.
pd.pivot(), pd.pivot_table(), pd.melt(): Reshape data.

Viewing and Inspecting Data


df.head(), df.tail(): View the first/last rows.
df.info(): Get a summary of the DataFrame.
df.describe(): Summary statistics.
df.shape, df.size, df.dtypes: Inspect dimensions and types.
df.columns, df.index: Get column names or index.

Indexing and Selection


df.loc[], df.iloc[], df.at[], df.iat[]: Access data by label or position.
df.filter(): Subset rows/columns.
df.query(): Query using a string expression.
df.sample(): Random sampling.

Data Cleaning
df.isna(), df.notna(), df.fillna(), df.dropna(): Handle missing values.
df.duplicated(), df.drop_duplicates(): Remove duplicates.
df.replace(): Replace values.
df.astype(): Change data type.
df.clip(): Limit values to a range.
df.rename(): Rename columns or rows.

Data Transformation
df.apply(), df.applymap(), df.map(): Apply functions element-wise.
df.transform(): Apply a function to transform groups.
df.pivot(), df.pivot_table(), pd.melt(): Reshape data.
df.sort_values(), df.sort_index(): Sort data.
df.set_index(), df.reset_index(): Modify the index.
df.cumsum(), df.cumprod(), df.cummin(), df.cummax(): Cumulative
operations.

Data Aggregation
df.groupby(), df.resample(), df.rolling(), df.expanding(): Grouping and
rolling computations.
df.agg(): Apply aggregation functions.
df.sum(), df.mean(), df.median(), df.var(), df.std(), df.min(), df.max(),
df.count(), df.mode(): Basic aggregation methods.

String Methods
df.str.contains(), df.str.replace(), df.str.split(), df.str.strip(), etc.: String
manipulation methods.

DateTime Methods
pd.to_datetime(): Convert to datetime.
df.dt.year, df.dt.month, df.dt.day, etc.: Extract components.
df.dt.to_period(), df.dt.to_timestamp(): Convert periods.

File I/O
df.to_csv(), df.to_excel(), df.to_sql(), df.to_json(), df.to_html(), etc.:
Save data.

Merging, Joining, and Concatenation


pd.concat(): Concatenate along a particular axis.
pd.merge(), df.merge(): Merge datasets.
df.join(): Join on indices.

Mathematical Operations
df.add(), df.sub(), df.mul(), df.div(): Element-wise arithmetic.
df.abs(), df.round(), df.sqrt(), df.clip(): Mathematical functions.

Visualization
df.plot(), df.hist(), df.boxplot(), etc.: Basic plotting.
pd.plotting.scatter_matrix(), pd.plotting.parallel_coordinates():
Advanced plots.

Advanced DataFrame Operations


df.explode(): Expand list-like elements into rows.
df.unstack(), df.stack(): Reshape hierarchical index data.
df.corr(), df.cov(): Correlation and covariance.

You might also like