Skip to content

feat: order the columns of every DataFrame the same way - #33

Merged
jaimeib merged 3 commits into
mainfrom
feat/column-order
Nov 26, 2026
Merged

jaimeib merged 3 commits into
mainfrom
feat/column-order

Conversation

@jaimeib

@jaimeib jaimeib commented Nov 26, 2026

Copy link
Copy Markdown
Member

What

flatten.order_columns gives every DataFrame the same column order:

  1. When: timestamp, or start and end for an aggregate.
  2. What the series is: zone, the other zone of a flow (source, destination, origin), the type (production_type, footprint_type, impact_type, factor_type) and scope.
  3. value and unit.
  4. The quality and the provenance of the data (valid, zone_status, data_state, datasource, coverage...), in the order of the API.
  5. updated_at.

source is the other zone only next to a zone; in the factors it is where the factor comes from (UNECE) and stays with the provenance. get_zones and get_status keep their columns.

Example: get_generation goes from zone, unit, valid, zone_status, production_type, data_state, datasource, timestamp, value, updated_at to timestamp, zone, production_type, value, unit, valid, zone_status, data_state, datasource, updated_at.

Why

The order followed the nesting of the JSON of each endpoint: some tables started with the zone and others with the type, what identifies a series was mixed with the quality of the data, and the unit was far from the value. The client is not published yet, so the order can change now without breaking anyone.

Also

The example notebook asks the factors with the same 6-hour window as the other cells (without a range the API answered with the current interval, empty until it is published; wattnet/wattnet-api#63 fixes that) and is run again against the API with the new order: every cell has its output.

Tests

  • The tests that pin the order per payload shape ask the new one; two new tests for source in the factors and next to a zone.
  • Full tox green, coverage 100%.
  • The README tells the order of the columns.

The columns followed the nesting of the JSON of each endpoint, so some tables
started with the zone and others with the type, what identifies a series was
mixed with the quality of the data, and the unit was far from the value.

Every DataFrame now has first when (timestamp, or start and end for an
aggregate), then what the series is (zone, the other zone of a flow, the type
and the scope), then value and unit, then the quality and the provenance of
the data in the order of the API, and updated_at last. source is the other
zone only next to a zone; in the factors it is where the factor comes from.

The example notebook asks the factors with the same window as the other cells
(without a range the API answered with the current interval, empty until it is
published) and is run again with the new order.
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

The client is published as 1.0.0 for a stable API, as wattnet-api,
wattnet-storage and wattnet-core already declare.
@jaimeib
jaimeib merged commit 6eb7455 into main Nov 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant