Skip to content

Add pandas DataFrame integration for batch experiment processing #6

@defnalk

Description

@defnalk

Summary

The current API operates on raw arrays / scalars per measurement. Real pilot-plant workflows produce CSV exports with multiple steady-state runs per file (e.g. experiments A–E in `ExperimentLabels`). Users have to manually slice rows, call `analyse_exchanger` per run, and re-assemble results.

A thin DataFrame integration would let users go from "raw plant CSV" to "results table" in one call.

Motivation

  • Aligns with the unreleased item already listed in `CHANGELOG.md` ("Pandas DataFrame integration for batch experiment processing")
  • Removes ~30 lines of glue code per analysis script
  • Enables direct comparison across experiments without manual bookkeeping

Proposed API

```python
import pandas as pd
from meapy.heat_transfer import analyse_exchanger_batch

df = pd.read_csv("plant_data.csv")
results = analyse_exchanger_batch(
df,
column_map={
"mea_flow_kg_h": "FT103",
"t_mea_in_c": "TT201",
# ...
},
fixed={"area_m2": 0.30, "cp_mea_j_kg_k": 3940},
group_by="experiment_label",
)

results is a DataFrame indexed by experiment_label with columns

u_w_m2_k, lmtd_k, efficiency, effectiveness, ntu, ...

```

Acceptance criteria

  • `analyse_exchanger_batch` accepts a DataFrame plus a column-name map and a dict of fixed parameters
  • Optional `group_by` argument averages across runs within a group before analysis
  • Returns a DataFrame with one row per group (or per input row if no grouping)
  • Raises a clear `ValueError` listing missing columns rather than `KeyError` from a downstream lookup
  • Pandas added as an optional dependency (`meapy[pandas]`), not a hard requirement
  • Equivalent batch helper for `koga_profile` (`mass_transfer.koga_profile_batch`)
  • Unit tests cover: happy path, missing column, mixed dtypes, empty groups, partial NaN rows
  • Example notebook or script in `examples/` showing end-to-end use against a synthetic CSV
  • CHANGELOG entry under Unreleased → Added

Out of scope

  • Polars integration (separate ticket if requested)
  • Direct database (Postgres/SQLite) connectors

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions