DevOps · pandas
Why Every DevOps Engineer Should Learn pandas in 2026
Quick summary — why DevOps engineers should learn pandas
DevOps engineers should learn pandas in 2026 because it answers operational questions fast: which endpoints return the most errors in logs, which pipeline stage is slowing builds, which service or team drives a cloud cost increase and how incident restore times are trending, using short scripts you can rerun every week.
In this guide you will learn:
- Analysing logs — with pandas.
- Pipeline duration — and failure analysis.
- Cloud cost exports — and incident trends.
- A weekly ops report — template.
- Interview questions — on data-driven operations.
SECTION 01Analysing logs with pandas
Command-line tools such as grep and awk are great for quick searches, but questions like 'which endpoints had the highest error rate per hour yesterday?' are easier in pandas. You parse log lines into columns once, then group, filter and count in any way you need. This is especially useful after an incident, when you need clear facts quickly:
| Question | pandas step | Example | Output |
|---|---|---|---|
| Error rate by endpoint | groupby + mean of status >= 500 | /api/orders 4% | Problem endpoints |
| Errors per hour | resample('h') | Spike at 14:00 | When it started |
| Slowest requests | nlargest on duration | Top 10 slow URLs | Performance targets |
| Top client IPs | value_counts | One IP sending most traffic | Possible abuse |
import re
import pandas as pd
LINES = [
'10.0.0.1 - - [05/Mar/2026:14:01:02 +0530] "GET /api/orders HTTP/1.1" 200 512 0.120',
'10.0.0.2 - - [05/Mar/2026:14:01:05 +0530] "GET /api/orders HTTP/1.1" 500 98 1.900',
'10.0.0.1 - - [05/Mar/2026:14:02:10 +0530] "POST /api/login HTTP/1.1" 200 210 0.300',
'10.0.0.3 - - [05/Mar/2026:15:10:00 +0530] "GET /api/orders HTTP/1.1" 502 98 2.400',
]
PATTERN = re.compile(r'(\S+) - - \[(.+?)\] "(\S+) (\S+) \S+" (\d{3}) (\d+) ([\d.]+)')
rows = [m.groups() for line in LINES if (m := PATTERN.match(line))]
df = pd.DataFrame(rows, columns=["ip", "time", "method", "path", "status", "bytes", "seconds"])
df["time"] = pd.to_datetime(df["time"], format="%d/%b/%Y:%H:%M:%S %z")
df[["status", "bytes"]] = df[["status", "bytes"]].astype(int)
df["seconds"] = df["seconds"].astype(float)
df["is_error"] = df["status"] >= 500
print(df.groupby("path")["is_error"].mean().mul(100).round(1).rename("error_%"))
import pandas as pd
# Assume df from the previous tab; here a small stand-in
df = pd.DataFrame({
"time": pd.to_datetime(["2026-03-05 14:01", "2026-03-05 14:20", "2026-03-05 15:10", "2026-03-05 15:40"]),
"is_error": [False, True, True, True],
})
hourly = df.set_index("time").resample("h")["is_error"].agg(["count", "sum"])
hourly["error_%"] = (hourly["sum"] / hourly["count"] * 100).round(1)
print(hourly)
SECTION 02Pipeline durations and failure rates
When developers say 'the pipeline feels slow', data settles the discussion. Most CI tools let you export or query run history with stage names, durations and results. pandas can show median and slowest durations per stage, failure rates by branch and trends over weeks, so you improve the stage that really matters instead of guessing:
| Metric | pandas approach | Why it matters | Action |
|---|---|---|---|
| Median stage duration | groupby('stage').median() | Typical wait time | Optimise the slowest stage |
| 95th percentile duration | quantile(0.95) | Worst common cases | Fix flaky or slow tests |
| Failure rate by stage | mean of failed flag | Where builds break | Improve tests or setup |
| Weekly trend | resample('W') | Getting better or worse | Track improvements |
import pandas as pd
runs = pd.DataFrame({
"run_id": [1, 1, 1, 2, 2, 2, 3, 3, 3],
"stage": ["install", "test", "build"] * 3,
"seconds": [60, 420, 90, 65, 610, 95, 58, 400, 88],
"result": ["ok", "ok", "ok", "ok", "failed", "skipped", "ok", "ok", "ok"],
})
summary = runs.groupby("stage").agg(
median_s=("seconds", "median"),
p95_s=("seconds", lambda s: s.quantile(0.95)),
failure_rate=("result", lambda r: (r == "failed").mean()),
).sort_values("median_s", ascending=False)
print(summary)
#!/usr/bin/env bash
# Export recent workflow runs to JSON with the GitHub CLI
set -euo pipefail
gh run list --limit 100 \
--json databaseId,workflowName,conclusion,createdAt,updatedAt \
> runs.json
python - <<'PY'
import pandas as pd
df = pd.read_json("runs.json")
df["minutes"] = (pd.to_datetime(df["updatedAt"]) - pd.to_datetime(df["createdAt"])).dt.total_seconds() / 60
print(df.groupby("workflowName")["minutes"].describe().round(1))
print(df["conclusion"].value_counts())
PY
SECTION 03Cloud cost exports and incident trends
Cloud providers can export detailed billing data as CSV, with service, resource, tags and cost per day. pandas can group it by service, environment or team tag to find what changed. Incident records, from a ticket tool or spreadsheet, can be analysed the same way to track time to restore and recurring causes. Both turn vague feelings into facts you can act on:
| Data | Question | pandas step | Decision supported |
|---|---|---|---|
| Cost export | Which service grew most? | pivot by month and service | Where to optimise |
| Cost export | How much is untagged? | filter missing tag | Enforce tagging |
| Incident log | Time to restore trend | groupby month, median | Measure reliability work |
| Incident log | Most common causes | value_counts on cause | Prevent repeats |
import pandas as pd
# Small stand-in for a billing export (made-up values)
cost = pd.DataFrame({
"date": pd.to_datetime(["2026-01-10", "2026-01-20", "2026-02-10", "2026-02-20", "2026-02-25"]),
"service": ["Compute", "Storage", "Compute", "Storage", "Database"],
"team": ["web", "data", "web", None, "data"],
"cost": [120.0, 40.0, 180.0, 42.0, 75.0],
})
cost["month"] = cost["date"].dt.to_period("M").astype(str)
print(cost.pivot_table(index="service", columns="month", values="cost", aggfunc="sum", fill_value=0))
print("untagged cost:", cost.loc[cost["team"].isna(), "cost"].sum())
import pandas as pd
incidents = pd.DataFrame({
"opened": pd.to_datetime(["2026-01-03 10:00", "2026-01-18 22:10", "2026-02-07 09:30", "2026-02-21 14:00"]),
"resolved": pd.to_datetime(["2026-01-03 12:30", "2026-01-19 01:10", "2026-02-07 10:15", "2026-02-21 14:40"]),
"cause": ["bad deploy", "disk full", "bad deploy", "config change"],
})
incidents["restore_min"] = (incidents["resolved"] - incidents["opened"]).dt.total_seconds() / 60
incidents["month"] = incidents["opened"].dt.to_period("M")
print(incidents.groupby("month")["restore_min"].median())
print(incidents["cause"].value_counts())
SECTION 04Weekly ops report template
Use these templates to build a weekly operations report with pandas:
# pip install pandas tabulate
import pandas as pd
def section(title: str, df: pd.DataFrame) -> str:
return f"## {title}\n\n{df.to_markdown()}\n"
pipelines = pd.DataFrame({"stage": ["test", "build"], "median_s": [420, 90]}).set_index("stage")
costs = pd.DataFrame({"service": ["Compute", "Database"], "change_%": [50.0, 12.5]}).set_index("service")
incidents = pd.DataFrame({"metric": ["count", "median restore min"], "value": [2, 42]}).set_index("metric")
report = "# Weekly ops report\n\n" + section("Pipelines", pipelines) + section("Costs", costs) + section("Incidents", incidents)
open("weekly_ops_report.md", "w").write(report)
print(report)
# Weekly ops report (template)
1. Pipelines: median and p95 duration per stage; failure rate
2. Errors: top endpoints by 5xx rate; any spikes
3. Costs: change by service vs last week; untagged cost
4. Incidents: count, median time to restore, causes
5. Actions: one improvement for next week, with owner
Week 1 pandas basics: DataFrames, read_csv, read_json
Week 2 Parse logs with regex into DataFrames
Week 3 groupby, resample, quantiles for pipeline data
Week 4 Cost export and incident analysis
Week 5 Automate the weekly report; schedule it
SECTION 05Tips for DevOps engineers learning pandas
These habits make pandas useful in day-to-day operations:
- Start from a real question — such as 'why are builds slower?'.
- Parse once, reuse often — save parsed logs as Parquet or CSV.
- Use percentiles — averages hide the worst cases.
- Track untagged costs — it shows tagging gaps.
- Share short reports — one page with an action beats a long dump.
SECTION 06Interview Q&A — data-driven operations
Q1How would you find which endpoint causes most errors?
Parse the access logs into a table, flag 5xx responses and group by endpoint to compute error counts and rates.
Q2Why use the 95th percentile for durations?
It shows the slow cases most users or developers experience regularly, which averages can hide.
Q3How would you investigate a cloud cost increase with data?
Export billing data, compare costs by service, region and tag between periods, and find new or growing resources.
Q4What is mean time to restore and why track it?
The average time to recover from incidents; tracking it shows whether reliability work is making recovery faster.
Q5When would you use pandas instead of grep or awk?
When you need grouping, joins, time-based summaries or repeated analysis that would be awkward with command-line tools.
SECTION 07Test yourself — data-driven operations quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 08Frequently asked questions
Do DevOps engineers need pandas?
It is not mandatory, but pandas is very useful for analysing logs, pipeline history, cost exports and incident data quickly.
Is pandas better than a monitoring tool?
No, they serve different purposes. Monitoring tools watch systems in real time; pandas is for ad-hoc and periodic analysis of exported data.
Can pandas handle large log files?
pandas works well for many log files that fit in memory. For very large data, read in chunks, filter early or use tools built for big data.
How long does it take a DevOps engineer to learn pandas basics?
With Python basics, core pandas loading, filtering, groupby and time-based summaries can be learned in a couple of weeks of practice.
What pandas project suits a DevOps portfolio?
A weekly ops report that parses sample logs, analyses pipeline durations, summarises a sample cost export and tracks incidents.
SECTION 09Related reads
Classroom & online · Noida
Build DevOps skills with data in mind
Our DevOps Training Course covers Linux, Git, CI/CD, Docker, Kubernetes, cloud, Terraform and monitoring, with scripting practice for automation and reporting.
Talk to a counsellor for current fees- CI/CD and containers
- Kubernetes and cloud
- Monitoring
- Weekday & weekend batches