Sub topic 14
Ecosystem, team skills, and deployment
This chapter assumes you have read the profiles of pandas, Polars, DuckDB, and Spark. It also assumes you can write basic Python and SQL. Performance is only one input to a tool choice. A tool that is twice as fast but that nobody on your team can debug, or that does not fit your deployment target, often costs more than it saves. This chapter covers the three non-performance factors: the ecosystem around each tool, the skills of the people who will maintain the code, and the environment where the code will run.
Ecosystem: what surrounds the DataFrame
A data tool rarely works alone. It reads from storage, feeds plotting and machine learning libraries, and runs inside schedulers and notebooks. The size of that surrounding ecosystem differs a lot between the four tools.
| Factor | pandas | Polars | DuckDB | Spark |
|---|---|---|---|---|
| Main interface | Python DataFrame | Python DataFrame (also Rust, others) | SQL (Python, CLI, many languages) | DataFrame and SQL (Python, Scala, Java, R) |
| Library support | Widest: most Python libraries accept pandas | Growing, often through conversion | Reads pandas, Polars, and Arrow objects | Large, with its own connectors and ML library |
| Typical runtime | Python process | Python process | Python process or standalone CLI | Cluster or local driver plus executors |
| Install weight | Light | Light | Light | Heavy (JVM and cluster configuration) |
pandas
pandas has the largest ecosystem for in-memory analysis. Plotting libraries, scikit-learn, statistics packages, and many tutorials and Stack Overflow answers assume pandas input. Many libraries accept a pandas DataFrame directly, so pandas is often the last step before handing data to a model or a chart. If your pipeline ends in one of those libraries, you will probably produce a pandas DataFrame at some point, even if earlier steps used another engine.
Polars
Polars has a smaller but growing ecosystem. Many libraries still expect pandas or NumPy input, so you often convert at the boundary with to_pandas() or to_numpy(). The conversion is usually cheap relative to the processing before it, but it is one more step to write and test. Polars also has its own expression syntax. Code written for pandas does not translate line by line, so an existing codebase cannot adopt it by changing an import.
DuckDB
DuckDB is an embedded database. It runs inside your process, so it has no server to install or operate. Its ecosystem advantage is SQL: analysts, BI tools, and dbt-style workflows already know it. It also queries pandas DataFrames, Polars DataFrames, and Arrow tables by variable name, which makes it a good bridge between the other tools.
Spark
Spark has the broadest platform ecosystem. It connects to many storage systems, streaming sources, and table formats, and managed Spark services exist on every major cloud. The cost is that the ecosystem comes bundled with the cluster. You rarely use Spark's strengths without also adopting its deployment model.
Team skills
Choose with the team that will own the code in mind, not only the person writing it first.
Match the tool to existing knowledge
- A team of analysts fluent in SQL can be productive in DuckDB on the first day. The same team would need weeks to become fluent in Polars expressions.
- A team with years of pandas code will find pandas the cheapest tool to maintain, even if it is not the fastest.
- A data engineering team already running Spark clusters has the operational skills Spark demands. A team without them does not.
Count the learning cost honestly
Learning cost has two parts. The first is syntax: how long until someone writes correct code. The second is the mental model: how long until someone predicts performance and debugs surprises. Polars syntax is quick to read, but its lazy model, covered in the earlier chapter on lazy evaluation, takes longer to internalize. Spark syntax resembles Polars and SQL, but understanding partitions and shuffles is what lets someone fix a slow job.
Hiring and onboarding
pandas knowledge is the most common among data practitioners, and SQL knowledge is nearly universal. Spark skills are common among data engineers but rarer among analysts. Choosing a less common tool is fine, but plan for training time and write down your conventions.
Code review and debugging
Eager code is easier to step through. You can print an intermediate DataFrame in pandas and see real values. In lazy tools you inspect the plan instead, as in this Polars example:
import polars as pl
lf = (
pl.scan_parquet("sales.parquet")
.filter(pl.col("revenue") > 0)
.select("region", "revenue")
)
print(lf.explain())Reading plans is a skill. Teams that adopt lazy tools should practice it, because it is the main way to debug performance.
Deployment: where the code runs
The same query behaves differently depending on where it runs. Check each of the following against your target environment.
Laptop and notebook
All four tools run on a laptop. pandas, Polars, and DuckDB install with a single pip install and start instantly. Spark can run in local mode on a laptop, but it needs a Java runtime and has a noticeable startup time. Local mode is useful for developing Spark code, but it does not give you cluster behavior.
Single server or container
For scheduled jobs in a container, the lightweight tools are easy to package. A small image with Python and DuckDB or Polars can start in a second or two. Resource limits matter here. Container memory limits are enforced strictly. A pandas job that exceeds the limit is killed by the operating system, often without a helpful Python error. Set the container limit with the memory estimates from the earlier chapter on memory in mind, and leave headroom for intermediate copies.
Serverless and short-lived functions
Serverless functions have size limits on packages, short time limits, and limited memory. DuckDB and Polars are compact and start fast, so they fit better than Spark. Check the package size limit before you commit, since some bundles with pandas and Arrow are large.
Clusters and managed platforms
Spark is the expected choice when your organization already runs a platform built on it, or when data truly exceeds a single machine. Managed services reduce the operational burden but add cost and a vendor-specific layer. If your company has such a platform, using it is often cheaper than building your own deployment for another tool, even for jobs a single node could handle. The cost to compare is the total cost of ownership, not just the compute bill.
Operational concerns
- Dependencies. Pin versions. Polars and DuckDB release frequently, and behavior can change between versions. pandas has also changed defaults across major versions.
- Observability. Spark ships a web UI that shows stages and shuffles. Single-node tools rely on logging, timing, and query plans that you collect yourself.
- Cost. Idle clusters cost money. A single-node tool on a modest machine has a predictable cost and no idle cluster.
- Security and governance. Check authentication, access control, and audit requirements. Managed platforms often provide these. In a single-process tool you must supply them through the surrounding infrastructure.
A worked comparison
Consider a team of four analysts who know SQL and some pandas. They produce a daily report from 20 GB of Parquet files, and the output feeds a plotting library.
- Ecosystem. The final step needs a pandas DataFrame for plotting.
- Skills. The team knows SQL well and pandas moderately.
- Deployment. The job runs on one scheduled container with 32 GB of memory. There is no Spark platform.
DuckDB fits all three. The team writes SQL, DuckDB reads the Parquet files directly and aggregates them down to a small result, and the .df() call hands a pandas DataFrame to the plotting code. No cluster is needed. The decision follows from the team and the environment, with performance as a confirming check.
import duckdb
report = duckdb.sql(
"SELECT region, sum(revenue) AS revenue "
"FROM 'sales.parquet' GROUP BY region"
).df()
print(report)The same facts could point elsewhere. If the company already ran a managed Spark platform with a data engineering team, and the report was one job among hundreds there, Spark could be the cheaper choice overall, even though the data is small.
Common mistakes
- Choosing by benchmark alone. A faster tool that the team cannot maintain creates risk that the speedup does not repay.
- Underestimating Spark's operational cost. Cluster setup, tuning, and monitoring are ongoing work.
- Ignoring the output consumer. If downstream code requires pandas, plan the conversion and check that it fits in memory.
- Mixing too many tools without a reason. Each tool adds dependencies and conventions. Add one only when it solves a specific problem.
- Forgetting version drift. Unpinned dependencies make results change silently between runs.
Exercise
A team of six SQL-fluent analysts runs a nightly job on one 16 GB container. The job reads 3 GB of Parquet, aggregates it, and passes a small result to a charting library that needs a pandas DataFrame. The company has no Spark platform. Which tool would you pick, and which two of the factors from this chapter justify it?
Show answer
DuckDB is a good fit. The team's SQL skills make it productive immediately (team skills), and it runs inside a single container with no cluster (deployment). It can also return the small result as a pandas DataFrame with .df() for the charting library (ecosystem). Polars would also work technically, but it would cost learning time with no deployment benefit.
Exercise
Your organization runs a managed Spark platform with a dedicated data engineering team. A new job processes 5 GB of data that would fit easily on one machine. Give one argument for using Spark anyway and one argument against.
Show answer
For: the platform already provides scheduling, monitoring, access control, and skilled operators, so the total cost of ownership may be lower than deploying and supporting a separate single-node tool. Against: Spark's startup and shuffle overhead make a small job slower than it needs to be, and cluster time costs money for work a single node could do cheaply.