Python Pandas examples
Copy-ready pandas snippets and data cleaning workflows for CSV files, Excel reports, dashboards, analysis notebooks and repeatable reporting tasks.
💡 Ideas for You
Learning resources for Python Pandas, data cleaning and analysis.
- Step-by-step books
Start with beginner-friendly step-by-step books and learning resources from Create & Learn.
- Python data guide
Helpful references for Python basics, notebooks and data workflows.
- Pandas books
Books for DataFrames, groupby, merge, pivot and data cleaning examples.
- Analytics projects
Resources for practical data analysis projects and reporting portfolios.
Some links in this section may be affiliate links. Choose only what is useful for your own work.
Browse Python Pandas examples
Use the search box or filter chips to find pandas examples by workflow. Results update in place without jumping or scrolling.
read_csv Examples
Load CSV files into DataFrames, handle delimiters, select columns, parse dates and clean common import issues.
Basicsread_excel Examples
Load Excel worksheets, choose sheets, skip header rows, read specific columns and combine sheets.
BasicsDataFrame Create Examples
Create DataFrames from dictionaries, lists, records and simple business tables.
BasicsSelect Columns Examples
Select one column, multiple columns, ranges of columns and columns by pattern.
BasicsRename Columns Examples
Rename columns, standardize messy headers and prepare imported files for analysis.
Basicssort_values Examples
Sort rows by revenue, dates, multiple columns and custom business priorities.
Basicshead tail sample Examples
Preview data with head, tail, sample and quick checks before cleaning or analysis.
FilteringFilter Rows Examples
Filter rows by conditions, dates, text, missing values and multiple business rules.
Filteringquery Examples
Use DataFrame.query for readable filters with numbers, text, dates and variables.
Filteringisin Examples
Filter rows where values match a list of regions, products, statuses or IDs.
Filteringbetween Examples
Filter numeric and date ranges such as revenue bands, age ranges and reporting windows.
Filteringloc and iloc Examples
Select rows and columns by labels or positions using loc and iloc.
FilteringDrop Rows Examples
Drop unwanted rows by index, condition, blank values and business rules.
CleaningMissing Values Examples
Find, fill, drop and report missing values in columns and business datasets.
Cleaningfillna Examples
Fill missing values with constants, averages, forward fill and group-based values.
Cleaningdropna Examples
Remove rows or columns with missing values while protecting important records.
Cleaningdrop_duplicates Examples
Remove duplicate customers, emails, products and records safely.
Cleaningreplace Examples
Replace values, standardize statuses, fix spelling and clean imported codes.
Cleaningastype Examples
Convert columns to strings, integers, floats, categories and booleans.
Cleaningto_numeric Examples
Convert messy number text to numeric values and handle invalid entries.
CleaningText Cleaning Examples
Clean names, codes and imported text using strip, lower, upper and replace.
Cleaningstr.contains Examples
Filter text by words, phrases, patterns and case-insensitive matches.
Cleaningextract Regex Examples
Extract IDs, dates, codes and parts of text into new columns.
Dates & Timesto_datetime Examples
Convert text dates to datetime and handle mixed date formats.
Dates & TimesDate Filter Examples
Filter records by date range, month, year, week and recent periods.
Dates & TimesDate Parts Examples
Create year, month, quarter, weekday and month name columns.
Dates & Timesresample Examples
Summarize time series by day, week, month, quarter and year.
Dates & TimesDate Difference Examples
Calculate days between dates, customer age, delivery time and overdue records.
Groupinggroupby Examples
Group sales, customers and operations data by category, region, date or status.
Groupingagg Examples
Create multiple summaries such as sum, mean, count and max in one table.
Groupingvalue_counts Examples
Count categories, statuses, product types and survey answers.
Groupingpivot_table Examples
Build Excel-like pivot tables with rows, columns, values and totals.
Groupingcrosstab Examples
Create cross-tab summaries for categories, segments and survey results.
GroupingRank Examples
Rank products, customers or regions by sales, margin or score.
GroupingRolling Window Examples
Calculate rolling averages, rolling sums and moving metrics over time.
Merge & Joinmerge Examples
Join sales, customers, products and lookup tables with keys.
Merge & JoinLeft Join Examples
Keep all records from the left table and bring matching lookup fields.
Merge & Joinconcat Examples
Stack files, append monthly reports and combine same-structure tables.
Merge & JoinCombine CSV Files Examples
Combine many CSV files from a folder into one DataFrame.
Merge & Joinmap Examples
Map codes to labels, replace IDs with names and create simple lookups.
Merge & JoinJoin Validation Examples
Check unmatched rows, duplicated keys and join quality after merging data.
Reshapingmelt Examples
Unpivot wide tables into long format for charts and analysis.
Reshapingpivot Examples
Turn long data into wide columns for reports and exports.
Reshapingstack and unstack Examples
Reshape MultiIndex data between long and wide formats.
Reshapingexplode Examples
Split list-like values into multiple rows for tags, products or skills.
ReshapingSplit Column Examples
Split full names, codes and combined fields into separate columns.
ReshapingWide to Long Examples
Convert spreadsheets with repeated period columns into tidy data.
Exportingto_csv Examples
Export cleaned DataFrames to CSV with selected columns and formatting choices.
Exportingto_excel Examples
Export reports to Excel sheets, multiple tabs and formatted workbook outputs.
ExportingExcelWriter Examples
Write multiple DataFrames to different Excel sheets in one workbook.
Exportingto_json Examples
Export records to JSON for APIs, apps and structured files.
ExportingReport Formatting Examples
Create readable exports with sorted columns, rounded values and renamed headers.
WorkflowsSales Summary Workflow Examples
Clean sales data, calculate KPIs and export a monthly summary.
WorkflowsCustomer Analysis Workflow Examples
Analyze customers by segment, spend, order count and retention signals.
WorkflowsInventory Workflow Examples
Flag low stock, summarize categories and prepare reorder lists.
WorkflowsExpense Cleaning Workflow Examples
Clean bank or expense exports, categorize transactions and summarize spend.
WorkflowsDashboard Prep Workflow Examples
Prepare tidy tables for dashboards in Excel, Power BI or web apps.
WorkflowsData Quality Checks Examples
Check blanks, duplicates, invalid values and unexpected categories before reporting.
WorkflowsMonthly Report Workflow Examples
Combine files, clean columns, summarize results and export a monthly report.
WorkflowsContent Calendar Workflow Examples
Clean content calendars, track status and summarize workload by channel.
WorkflowsSurvey Analysis Workflow Examples
Clean survey responses, summarize answers and prepare charts.
WorkflowsLog Analysis Workflow Examples
Parse logs, count events, find errors and summarize activity over time.