Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

Data Analysis with Pandas

By Kokil Thapa | Last reviewed: September 2026

Data Analysis with Pandas is how you turn raw exports into answers. Web apps dump orders, leads, and logs into CSV or JSON. Spreadsheets break when row counts hit six figures. Pandas gives you a fast table engine in Python. You filter, aggregate, and spot bad rows before they reach a custom software dashboard or client report. This guide walks through a workflow I use when Laravel exports need serious crunching outside PHP.

What is Data Analysis with Pandas and when should developers use it?

Pandas is a Python library built on NumPy. Its core object is the DataFrame—a labeled table like a spreadsheet with column types, indexes, and vectorised operations. You install it once and reuse the same patterns across sales reports, SEO crawl exports, and payment reconciliation files.

On production Laravel apps I maintain, PHP handles requests and business rules well. Heavy ad-hoc analysis on 500 MB CSV dumps is slower and harder to read in PHP alone. Pandas scripts run locally or in CI. They produce clean summary files that Laravel imports through API endpoints or scheduled jobs.

Reach for Pandas when you need repeatable analysis, not one-off cell formulas. Common triggers include monthly eCommerce sales rollups, lead-source breakdowns for law-firm portals, and log parsing before a technical SEO audit. Skip it for real-time streaming or ML training at scale—those jobs belong in warehouse tools covered in our data engineering overview.

Pandas Analysis PipelineRaw ExportCSV / JSON / SQLDataFrameTyped columnsClean + FilterNulls, dtypesAggregateGroup, pivotExploredescribe, value_countsValidateduplicates, rangesExport to AppCSV, JSON, Parquet for Laravel / BI
Data Analysis with Pandas follows a linear pipeline from raw exports through cleaning and aggregation to app-ready output.

How do you set up Pandas for your first data analysis project?

Start with a isolated virtual environment. Mixing Pandas with system Python on Ubuntu causes version conflicts during upgrades. Create a project folder, activate a venv, and install Pandas with pip.

Create the environment

python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install pandas pyarrow openpyxl

pyarrow speeds Parquet reads. openpyxl handles Excel exports from finance teams. Pin versions in requirements.txt so CI reproduces the same results six months later. The official Pandas installation guide lists optional dependencies for database connectors and performance extras.

Project layout that scales

Keep scripts small and named by task. A layout I reuse:

  • data/raw/ — untouched exports from Laravel or WooCommerce
  • data/processed/ — cleaned files ready for import
  • scripts/analyse_orders.py — one analysis per script
  • output/reports/ — CSV summaries with date stamps

Add data/raw/ to .gitignore. Client order files belong in secure storage, not Git. Commit only scripts and sample anonymised rows for tests. This mirrors test data management practices from pipeline work.

How do you load, clean, and explore datasets with Pandas?

Most web exports arrive as CSV. Loading is one line, but dtype guessing causes silent bugs. Order IDs become floats. Dates parse as objects. Always inspect immediately after load.

Load and inspect

import pandas as pd

df = pd.read_csv(
    "data/raw/orders_2026.csv",
    parse_dates=["created_at"],
    dtype={"order_id": "string", "customer_id": "string"},
)

print(df.shape)
print(df.dtypes)
print(df.head())
print(df.isna().sum())

df.info() and df.describe(include="all") give quick health checks. For JSON API dumps, use pd.read_json() or pd.json_normalize() when records nest fields. Validate structure with a JSON formatter before parsing nested payloads.

Clean common web-app export problems

  1. Drop duplicate rows on a natural key such as order_id.
  2. Fill or flag nulls in required columns—never silently drop paid orders.
  3. Normalise text: strip whitespace, lower-case emails for deduping.
  4. Parse currency columns to numeric; remove NPR or USD symbols first.
  5. Filter test accounts by email domain or a is_test flag.
df = df.drop_duplicates(subset=["order_id"])
df["email"] = df["email"].str.strip().str.lower()
df["amount_npr"] = (
    df["amount"]
    .astype(str)
    .str.replace(",", "", regex=False)
    .str.replace("Rs", "", regex=False)
    .astype(float)
)
df = df[df["status"] == "paid"]

On a grocery eCommerce project like Quick And Easy Nepalese Grocery, delivery-zone logic produced edge-case postcodes. Pandas let me isolate those rows before fixing zone rules in Laravel. The same pattern applies to any catalog with messy legacy imports.

Pandas Data Cleaning FlowMissing Valuesisna, fillna, dropnaDuplicatesdrop_duplicatesBad Typesastype, to_datetimeClean DataFrameReady for analysisText Normalisestr.strip, lowerOutlier Filterquery, betweenCategory Mapreplace, Categorical
Cleaning is the highest-value step in Data Analysis with Pandas—most export bugs hide in nulls, duplicates, and wrong dtypes.

How do you perform aggregation and group analysis in Pandas?

Once data is clean, aggregation answers business questions. How much revenue per city? Which lead source converts best? GroupBy splits rows by a key and applies functions per group.

GroupBy patterns for eCommerce and lead data

monthly = (
    df.groupby(df["created_at"].dt.to_period("M"))
    .agg(
        orders=("order_id", "count"),
        revenue_npr=("amount_npr", "sum"),
        avg_order=("amount_npr", "mean"),
    )
    .reset_index()
)

by_city = (
    df.groupby("city", observed=True)
    .agg(orders=("order_id", "nunique"), revenue=("amount_npr", "sum"))
    .sort_values("revenue", ascending=False)
)

.agg() with named outputs keeps column names readable in exports. Use observed=True on categorical columns to skip empty factor levels. For pivot-style views—months as columns, cities as rows—pd.pivot_table() replaces fragile spreadsheet formulas.

pivot = pd.pivot_table(
    df,
    index="city",
    columns=df["created_at"].dt.month,
    values="amount_npr",
    aggfunc="sum",
    fill_value=0,
)

Compare Pandas against SQL and spreadsheet workflows before you commit a stack. Each option fits different team skills and data sizes.

ApproachBest forWeaknessTypical cost
Pandas (Python)Repeatable scripts, mixed CSV/JSON, 1–10 GB locallyMemory-bound; not a production API serverFree; dev time only
SQL (MySQL 9.7 / PostgreSQL 18)Live app data, indexed queries, dashboardsAd-hoc exports need DBA help on busy prodHosting Rs 1,500–5,000/mo (~USD 11–37)
Excel / Google SheetsQuick one-offs, non-technical stakeholdersSlow and fragile above ~100k rowsLow; error-prone at scale
Warehouse + dbtTeam-wide metrics, scheduled pipelinesSetup overhead for small projectsCloud spend varies

For scheduled warehouse transforms, see dbt transform patterns. Pandas still wins for pre-warehouse exploration and one-off client reports on a enterprise reporting brief.

GroupBy Aggregation ModelFull DataFrame — all order rowsGroup: Kathmandu412 rowsGroup: Pokhara187 rowsGroup: Lalitpur256 rowssum: Rs 2.1Mcount: 412sum: Rs 890Kcount: 187sum: Rs 1.4Mcount: 256
GroupBy splits rows by a key column, then applies aggregation functions to produce one summary row per group.

How do you connect Pandas output to Laravel apps and business reports?

Analysis has no value until someone acts on it. Export summaries to formats your app already ingests. CSV works for manual review. Parquet suits large files. JSON feeds REST endpoints.

Export patterns

monthly.to_csv("output/reports/monthly_2026-09.csv", index=False)
by_city.to_json("output/reports/revenue_by_city.json", orient="records", indent=2)
df.to_parquet("data/processed/orders_clean.parquet", index=False)

In Laravel, import with Maatwebsite Excel for CSV or json_decode(file_get_contents(...), true) for small JSON summaries. For larger batches, load Parquet through a Python micro-script or push clean data back into MySQL with df.to_sql() inside a guarded admin command. Never expose raw analysis scripts on public URLs.

Booking platforms like Adventure Third Pole Trek generate seasonality reports—trek demand by month and region. Pandas builds those summaries offline. Laravel displays them in an admin chart. The split keeps the web app fast and the analysis reproducible.

Quality checks before you ship numbers

Wrong aggregates damage client trust faster than a slow page. Before exporting, assert row counts and totals against source SQL.

  • Compare df["amount_npr"].sum() to a MySQL SUM() on the same date range.
  • Assert no nulls in grouping keys you rely on.
  • Log min and max dates so partial exports are obvious.
  • Version output filenames with run date and script git hash.

These checks mirror data quality practices from pipeline engineering. They take five minutes and prevent embarrassing board slides.

Pandas to Production AppPandas ScriptCron / CI jobExport FilesCSV / JSON / ParquetLaravel AppImport + cacheAdmin DashboardCharts from cached summariesClient PDF ReportMonthly email attachmentValidate totals against SQL before publish
Data Analysis with Pandas feeds Laravel dashboards and client reports through versioned export files and validation checks.

What performance tips keep Pandas analysis fast on large exports?

Memory is the usual bottleneck, not CPU. A 2 GB CSV can expand to 6 GB in RAM after type inference and intermediate copies. Read only columns you need and push filters early.

cols = ["order_id", "created_at", "city", "amount_npr", "status"]
df = pd.read_csv("data/raw/orders_2026.csv", usecols=cols, parse_dates=["created_at"])
df = df[df["status"] == "paid"]  # filter before heavy work

Switch to dtype_backend="pyarrow" in newer Pandas releases for string-heavy columns. For files that exceed RAM, read in chunks with chunksize=50_000 and aggregate incrementally. That pattern resembles PHP generators for large datasets—same idea, different runtime.

Profile with %timeit in IPython or plain time.perf_counter() around hot paths. .apply() row loops are slow. Prefer vectorised string and datetime accessors. If analysis runs nightly, containerise the script and trigger it from GitLab CI alongside your Deployer pipeline. Keep Python analysis separate from PHP-FPM workers so a heavy job never blocks checkout.

SEO teams can combine Pandas with crawl exports for deeper cuts than GA4 alone. Our GA4 for SEO data analysis guide covers the marketing side. Pandas handles the raw URL-level merges. For broader automation, AI integration services can wrap recurring reports—still grounded in validated Pandas output, not hallucinated figures.

Key Takeaways

  • Install Pandas in a dedicated venv with pinned requirements.txt and never commit raw client exports to Git.
  • Always set dtype and parse_dates on load—silent type coercion causes the worst production report bugs.
  • Clean nulls, duplicates, and currency formatting before any GroupBy or pivot operation.
  • Validate aggregated totals against a SQL query on the same date range before publishing to stakeholders.
  • Export to CSV, JSON, or Parquet and let Laravel handle display—keep analysis scripts offline from public HTTP.
  • Use chunk reads and column pruning when exports exceed available RAM on a laptop or CI runner.

People Also Ask

Is Pandas enough for professional data analysis?

Pandas covers exploration, cleaning, and aggregation for tabular data up to low tens of gigabytes on a single machine. Teams needing shared metrics, role-based access, and scheduled pipelines eventually add SQL warehouses and tools like dbt. Pandas remains the fastest way to prototype those metrics before you codify them in SQL.

Can Pandas read directly from MySQL or PostgreSQL?

Yes. Use pd.read_sql() with a SQLAlchemy connection string pointing at MySQL 9.7 or PostgreSQL 18. Push filters into the SQL WHERE clause so the database returns fewer rows. Avoid pulling entire production tables into a laptop during peak hours.

How does Pandas compare to Excel for business reporting?

Excel wins for quick charts and stakeholder edits. Pandas wins for reproducibility, larger files, and scripted monthly runs. A Pandas script produces identical logic every month. Excel formulas drift when someone inserts a row or changes a range reference.

Do web developers need to learn Pandas?

Not every web developer needs it daily. If you ship reporting features, reconcile payment exports, or debug data issues beyond what Eloquent handles comfortably, a working Pandas skill saves hours. Treat it as a specialist tool in your stack, like Redis or queue workers—not a replacement for SQL in live apps.

Ship repeatable analysis, not one-off spreadsheets

Data Analysis with Pandas belongs in every full-stack toolkit where exports outgrow PHP loops and Excel limits. Start with one real CSV from your app. Clean it, group it, validate totals, and export a summary your Laravel admin can load tomorrow. When you need analysis baked into a product—or automated reporting across Nepal and international clients—contact us or browse the portfolio for examples of data-driven apps we have shipped. For related reading, see how to get started in data science and about the author.

Frequently Asked Questions

Pandas is a Python library that loads tabular exports into DataFrames, cleans missing values and types, groups and aggregates columns, then exports CSV or JSON summaries for dashboards and reports.

Pandas itself is free open source. You pay only developer time and optional CI runner minutes—not the Rs 1,500–5,000/month (~USD 11–37) typical for hosted SQL database analysis.

Use Pandas when exports exceed roughly 100k rows, you need repeatable monthly scripts, or mixed CSV and JSON breaks spreadsheet formulas. Excel stays fine for quick one-offs and stakeholder edits.

Reach for Pandas when PHP loops on 500 MB CSV dumps become slow and hard to read, but you still need repeatable analysis—not one-off cell formulas. Common triggers include monthly eCommerce sales rollups, lead-source breakdowns for law-firm portals, and log parsing before technical SEO audits. Skip it for real-time streaming or large-scale ML training; those belong in warehouse tools. Pandas scripts run locally or in CI and produce clean summary files Laravel imports through API endpoints or scheduled jobs.

Start with an isolated virtual environment on Ubuntu—mixing Pandas with system Python causes version conflicts during upgrades. Create a project folder, activate the venv, upgrade pip, then install pandas, pyarrow, and openpyxl. pyarrow speeds Parquet reads; openpyxl handles Excel exports from finance teams. Pin versions in requirements.txt so CI reproduces identical results six months later. The official Pandas installation guide lists optional dependencies for database connectors and performance extras if you need them later.

A layout that scales keeps scripts small and named by task: data/raw/ holds untouched exports from Laravel or WooCommerce; data/processed/ stores cleaned files ready for import; scripts/ contains one analysis file per task such as analyse_orders.py; output/reports/ holds CSV summaries with date stamps. Add data/raw/ to .gitignore—client order files belong in secure storage, not Git. Commit only scripts and sample anonymised rows for tests. This mirrors sensible test data management from pipeline work and keeps sensitive exports out of version control.

Most web exports arrive as CSV, but dtype guessing causes silent bugs—order IDs become floats and dates parse as objects. Always inspect immediately after load with shape, dtypes, head, isna().sum(), info(), and describe(include="all"). Explicitly set parse_dates for datetime columns and dtype for ID columns as string. For JSON API dumps, use read_json or json_normalize when records nest fields, and validate structure with a JSON formatter before parsing nested payloads. This upfront inspection prevents the worst production report bugs downstream.

Cleaning is the highest-value step—most export bugs hide in nulls, duplicates, and wrong dtypes. Drop duplicate rows on a natural key such as order_id. Fill or flag nulls in required columns; never silently drop paid orders. Normalise text by stripping whitespace and lower-casing emails for deduping. Parse currency columns to numeric by removing NPR or USD symbols and commas first. Filter test accounts by email domain or an is_test flag. On a grocery eCommerce project, this pattern isolated delivery-zone edge-case postcodes before fixing zone rules in Laravel.

Once data is clean, GroupBy splits rows by a key column and applies aggregation functions to produce one summary row per group. Use .agg() with named outputs so exported column names stay readable. Group by month using dt.to_period("M") for order counts, revenue sums, and average order values. Group by city with observed=True on categorical columns to skip empty factor levels. For pivot-style views—months as columns, cities as rows—pd.pivot_table() replaces fragile spreadsheet formulas. This answers questions like revenue per city or which lead source converts best.

Pandas fits repeatable scripts on mixed CSV and JSON files up to roughly 1–10 GB locally, at free tooling cost plus developer time. SQL on MySQL 9.7 or PostgreSQL 18 fits live app data, indexed queries, and dashboards, but ad-hoc exports need DBA help on busy production databases and hosting runs Rs 1,500–5,000/month (~USD 11–37). Pandas is memory-bound and not a production API server. SQL wins when data already lives in indexed tables. Pandas wins for pre-warehouse exploration and one-off client reports on exported dumps outside PHP.

Yes. Use pd.read_sql() with a SQLAlchemy connection string pointing at MySQL 9.7 or PostgreSQL 18. Push filters into the SQL WHERE clause so the database returns fewer rows instead of pulling entire production tables into a laptop during peak hours. This keeps analysis fast and avoids load on live app databases. For scheduled warehouse transforms at team scale, see dbt patterns—but direct SQL reads work well when you need a filtered slice for ad-hoc Pandas exploration before codifying metrics.

Export summaries to formats your app already ingests: CSV for manual review, Parquet for large files, JSON for REST endpoints. In Laravel, import CSV with Maatwebsite Excel or decode small JSON summaries with json_decode and file_get_contents. For larger batches, load Parquet through a Python micro-script or push clean data back into MySQL with df.to_sql() inside a guarded admin command. Never expose raw analysis scripts on public URLs. Booking platforms generate seasonality reports offline in Pandas; Laravel displays them in admin charts while keeping the web app fast.

Wrong aggregates damage client trust faster than a slow page. Before exporting, assert row counts and totals against source SQL—compare df amount sums to a MySQL SUM() on the same date range. Assert no nulls in grouping keys you rely on. Log min and max dates so partial exports are obvious. Version output filenames with run date and script git hash. These checks mirror data quality practices from pipeline engineering, take about five minutes, and prevent embarrassing board slides. Validated Pandas output feeds Laravel dashboards through versioned export files.

Memory is the usual bottleneck, not CPU—a 2 GB CSV can expand to 6 GB in RAM after type inference and intermediate copies. Read only columns you need with usecols and push filters early before heavy work. Switch to dtype_backend="pyarrow" in newer Pandas releases for string-heavy columns. For files exceeding RAM, read in chunks with chunksize=50_000 and aggregate incrementally. Avoid slow .apply() row loops; prefer vectorised string and datetime accessors. Profile hot paths with timeit or time.perf_counter(). Containerise nightly scripts and trigger from GitLab CI alongside Deployer so heavy jobs never block PHP-FPM workers.

Pandas covers exploration, cleaning, and aggregation for tabular data up to low tens of gigabytes on a single machine. Teams needing shared metrics, role-based access, and scheduled pipelines eventually add SQL warehouses and tools like dbt. Pandas remains the fastest way to prototype those metrics before codifying them in SQL. For web developers shipping reporting features or reconciling payment exports, a working Pandas skill saves hours—treat it as a specialist tool like Redis or queue workers, not a replacement for SQL in live apps. Start with one real CSV from your app and build from there.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: