Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →This pandas cheat sheet, checked against pandas 3.0.6 documentation dated September 17, 2026, gives you a practical path through the common tasks: load a file, inspect and select data, clean and transform it, summarize groups, reshape tables, and combine datasets. Each example assumes pandas is installed and that pd refers to the pandas library.
pandas provides Python data structures and analysis tools for exploring, cleaning, and processing tabular data such as spreadsheets and database tables. Its main table structure is the DataFrame. This guide focuses on choosing a command for the task rather than listing every method or option.
How to use this pandas cheat sheet
Start with the operation you need, then consult the official user guide for concepts and the API reference for exact signatures and parameters. The API reference assumes you already understand the underlying concepts, while the user guide explains them with examples. New to pandas? Begin with 10 minutes to pandas.
How do I read a CSV with pandas?
Use read_csv() to load a CSV file into a DataFrame. To save the result as a CSV, use to_csv():
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import pandas as pd
df = pd.read_csv("sales.csv")
df.to_csv("sales_clean.csv", index=False)
index=False prevents the DataFrame’s row labels from being written as an extra CSV column. pandas also provides read_* functions and to_* methods for formats such as Excel, SQL, JSON, and Parquet. Options vary by format; see the IO tools guide for supported formats and details.
How do I inspect a DataFrame?
Check a few rows and the structure before transforming data. These commands show a sample, column names and types, and a compact summary of numeric columns:
df.head()
df.info()
df.describe()
For a quick size check, use df.shape; it returns a pair of values in the order rows, columns. Inspection helps reveal unexpected column types or missing values before calculations depend on them.
How do I select rows and columns?
Use [] for a column or a Boolean row filter, .loc to select by labels, and .iloc to select by integer positions. Label-based selection and position-based selection are different; choose according to what identifies the rows and columns you want.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
# One column; result is a Series
amounts = df["amount"]
# Rows matching a condition
large_sales = df[df["amount"] > 100]
# Select rows and columns by labels
subset = df.loc[df["region"] == "West", ["region", "amount"]]
# Select by integer positions: first five rows, first two columns
sample = df.iloc[:5, :2]
Use the indexing and selecting data guide for slicing, alignment, and less common selection cases.
How do I clean and transform data?
Create a derived column
Column operations work across values without requiring an explicit Python loop over rows. For example, calculate a line total from price and quantity:
df["line_total"] = df["price"] * df["quantity"]
Handle missing values
Use isna() to identify missing values. Then decide whether to remove affected rows or fill values; that choice depends on what the missing entries mean in your data.
missing_by_column = df.isna().sum()
complete_rows = df.dropna()
filled = df.fillna({"quantity": 0})
Filling a missing value with zero is appropriate only when zero is a valid substitute for the missing value in that field. See the missing data guide for additional behavior and options.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Remove duplicate rows
drop_duplicates() removes duplicate rows. Pass a column name or list of column names to define which values determine duplication:
unique_records = df.drop_duplicates()
unique_customers = df.drop_duplicates(subset="customer_id")
Clean text values
For string columns, the .str accessor provides vectorized text operations. This example trims leading and trailing whitespace:
df["name"] = df["name"].str.strip()
For pandas 3.0, string behavior and the new string data type are version-sensitive. If you maintain code written for earlier releases, check the pandas 3.0 string migration guide rather than assuming behavior is unchanged.
How do I calculate summaries and group data?
For a whole-column summary, use methods such as mean(), sum(), or value_counts(), depending on the question. To calculate summaries for each category, use groupby(): it splits rows into groups, applies a calculation, and combines the results.
Recommended Free Tools
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
# Overall average
average_amount = df["amount"].mean()
# Total amount for each region
sales_by_region = df.groupby("region")["amount"].sum()
# Several summaries for each region
summary = df.groupby("region").agg(
total_amount=("amount", "sum"),
average_amount=("amount", "mean"),
order_count=("amount", "count"),
)
Use agg() when a group needs multiple summaries. The groupby guide covers split-apply-combine, custom aggregations, and related patterns; use the windowing guide when the calculation needs a rolling or other window over observations.
How do I reshape wide data to long format?
Use melt() when several measurement columns should become rows. Use pivot() to move long-form values into columns. A pivot expects the chosen index-and-column combinations to identify single values; when duplicates require aggregation, use pivot_table() instead.
# Wide: one row per person, with separate year columns
wide = pd.DataFrame({
"person": ["Ari", "Bo"],
"sales_2025": [12, 9],
"sales_2026": [15, 11],
})
# Long: year and sales become values in two columns
long = wide.melt(
id_vars="person",
var_name="year",
value_name="sales",
)
# Wide again, using a unique person/year pair
restored = long.pivot(index="person", columns="year", values="sales")
Read the reshaping and pivot tables guide for multi-index and aggregation cases.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How do I combine two DataFrames?
Choose the combining method based on how the tables relate. concat() stacks tables along an axis; merge() matches rows using key columns, like a database join; join() is commonly used to combine on indexes.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsBest Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
# Stack rows from similarly structured tables
all_months = pd.concat([january, february], ignore_index=True)
# Match customer records using a shared key
combined = orders.merge(customers, on="customer_id", how="left")
Before relying on a merge, check that the key columns mean the same thing in both tables and that their values have compatible types. Then inspect the resulting row count and unmatched records: duplicate keys can multiply rows, while join type affects which unmatched rows remain. See the merging, joining, and concatenating guide.
How do I work with dates and times?
Parse a date column during CSV import with parse_dates, or convert it afterward with to_datetime(). Once a column contains datetime values, the .dt accessor can extract date components:
df = pd.read_csv("sales.csv", parse_dates=["order_date"])
df["order_year"] = df["order_date"].dt.year
For time-based indexing, resampling, and time-series-specific behavior, use the time series guide.
Where should I look for more pandas help?
- 10 minutes to pandas is the recommended starting point for new users.
- The pandas 3.0.6 User Guide explains topics such as indexing, IO, missing data, grouping, reshaping, text, time series, and scaling.
- The API reference is the place to check exact function and method parameters.
- The official project recommends Python for Data Analysis by Wes McKinney as a book for learning pandas; see the project getting-started page.
For large datasets, consult the user guide’s scaling to large datasets section. It discusses approaches including loading less data, using efficient data types, and chunking; pandas is not a reason to ignore memory constraints.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

