Migration: 0.0 → 0.1¶
Single source of truth: edit this file only. The published docs include it from
docs/source/guides/migration_0.0_to_0.1.mdvia MyST{include}.
Breaking changes¶
Python 3.11 minimum¶
Python 3.10 is no longer supported. The StrEnum class (used internally) requires 3.11+.
to_networkx() renamed to export_to_networkx()¶
# Old
graph = data.to_networkx()
# New
graph = data.export_to_networkx()
Arrow-backed dtypes (when using pyarrow engines)¶
When triplets[arrow] is installed, the python_lxml_arrow and cython_pugixml_arrow engines
return DataFrames with string[pyarrow] and dictionary<...>[pyarrow] column dtypes instead of
plain object/str.
This affects code that:
Uses
.straccessor on filtered columns — may fail with"Can only use .str accessor with string values"Checks
dtype == objectordtype == strDoes in-place mutation on categorical columns
Fix: Convert to plain strings where needed:
# Before (may fail with pyarrow dtypes)
data[data.KEY.str.contains(pattern)]
# After (works with any dtype)
data[data["KEY"].astype(str).str.contains(pattern)]
To avoid arrow dtypes entirely, use the pandas-only engine:
data = pandas.read_RDF(files, engine="python_lxml_pandas") # always returns plain str dtypes
Dictionary-encoded KEY and INSTANCE_ID columns¶
With arrow engines, KEY and INSTANCE_ID columns are dictionary-encoded (categorical) by default.
This saves ~60% memory but may affect code that expects plain string columns:
# Check if a column is categorical
print(data["KEY"].dtype) # dictionary<values=string, indices=int32, ordered=0>[pyarrow]
# Convert to plain strings if needed
data["KEY"] = data["KEY"].astype(str)
Deprecations¶
All functions in rdf_parser.py now emit DeprecationWarning and delegate to the new modules.
They will be removed in 0.2.
Import paths¶
Old (0.0) |
New (0.1) |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
All other |
|
The old filter_by_type name (and other pre-0.1 tool names below) still work via
compatibility aliases but emit DeprecationWarning.
tools renames¶
Function names follow <action>_<format>_<qualifier> since 0.1 (“triplets” = the
long ID/KEY/VALUE/INSTANCE_ID table, “tableview” = the pivoted per-class table).
Old names keep working but emit DeprecationWarning; they will be removed in 0.2.
Old (0.0) |
New (0.1) |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note: 0.1.0rc4 briefly misnamed these two as
set_triplets_value_by_key(_and_id); corrected before 0.1.0 — treated as an rc-only bug, no compatibility aliases.
The renames apply to triplets.tools.*, root methods on DataFrames/connections, and the
.triplets accessor namespace (pandas, polars, and DuckDB).
cgmes_tools renames¶
Old names keep working in 0.1 but emit DeprecationWarning; they will be removed in 0.2.
Old (0.0) |
New (0.1) |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Visualization helpers were renamed from draw_relations_* to draw_references_* so they
align with tools.references_*. The graph renderer is internal (_draw_references_graph);
there is no public draw_relations_graph API in 0.1.
Triplets are always strings (or null)¶
Since 0.1, the tools enforce that ID/KEY/VALUE contain only strings or
nulls — never raw numbers or other objects:
tableview_to_triplets(and the tableview update functions built on it) returns a nullablestringdtype: numbers fromstring_to_number=Truetableviews become text, and empty tableview cells stay null — previously they became literal"nan"strings.set_value_at_key/set_value_at_key_and_idnormalize values withstr();Nonestays null (previously polars stored the literal string"None", and pandas let raw ints intoVALUE— which crashed the compiled CIM XML export withExpected bytes, got a 'int' object).
If your code built triplet rows with numeric VALUEs by hand, the exports now
tolerate them, but converting with data["VALUE"].astype(str) keeps your data
within the contract.
export_to_cimxml exports schema-defined content only by default¶
export_undefined now defaults to False: internal structures
(Distribution, NamespaceMap and any class/attribute without a schema
definition) are no longer written into CIM XML exports. Pass
export_undefined=True to include them — they are emitted under the
http://triplets# namespace (making the output valid, strict-parser-safe
RDF/XML; previously they were non-namespaced elements).
Profile resolution is schema-driven now: the schema’s own ProfileMetadata
(keyword, versionIRI, conformsTo) is matched against the instance
header (Model.messageType, keyword, Model.profile, conformsTo), so
CGMES 2.4.15, CGMES 3.0 and NetworkCode headers all resolve to the right
profile section.
Accessor namespace¶
The old monkey-patched root methods (data.type_tableview(...)) still work but the
recommended approach is the .triplets namespace:
# pandas / polars — recommended
df.triplets.type_tableview("ACLineSegment")
# DuckDB connection — same method names, different object
con.triplets.type_tableview("ACLineSegment").df()
All three backends expose the same tool and export names on .triplets. DuckDB
results are relations — call .df() or .pl() when you need a DataFrame.
Root-level methods remain on pandas/polars DataFrames and DuckDB connections for
backwards compatibility.
New module structure¶
triplets/
├── parser/ # parse XML to DataFrames (3 engines)
├── tools/ # query, filter, diff, transform (pandas + polars + duckdb)
├── export/ # Excel, CSV, CIM XML, N-Quads, NetworkX
├── cli/ # cim-spreadsheet, cim-diff CLI tools
├── cgmes_tools/ # CGMES metadata, visualization, data quality
├── rdfs_tools/ # RDF Schema utilities
├── export_schema/ # ENTSO-E JSON schema files
├── _accessor.py # .triplets namespace registration
└── rdf_parser.py # deprecated shim (will be removed in 0.2)