feat(dataframe): Spalten-Ergonomie für sclass.DataFrame (PR2)#52
Merged
Conversation
Erstklassige, schreibdurchgängige Spalten-API plus konsistentes Synchronisieren
der column_metadata mit den df-Spalten. Strikt additiv, 100 % Coverage.
- set_column(name, *, unit/label/description/ontology/required/dtype): annotiert
eine Spalte; nur gesetzte Felder ändern sich, vorhandene Annotationen bleiben
(über Metadata.set_attr). Warnt, wenn die Spalte nicht im df existiert.
- get_column(name) -> Attribute (oder None).
- col-Accessor (ColumnAccessor, gespiegelt von AttrAccessor in interactive.py):
df.col.weight / df.col["weight"] liefern das Spalten-Attribute (Autocomplete via
__dir__); Felder direkt mutierbar (df.col.weight.unit = "kg"). Zuweisung
df.col.x = ... wirft bewusst AttributeError und verweist auf set_column.
- column_units: Mapping {Spalte: Einheit} in df-Spaltenreihenfolge.
- _sync_column_metadata() im df-Setter: ergänzt neue Spalten und prunt Attribute
zu entfernten Spalten (prune=True bei Neuzuweisung); bei der Konstruktion
gelieferte column_metadata bleibt erhalten (prune=False, nur Waisen-Warnung).
- Tests: tests/test_sclass_dataframe_columns.py (set/get, Accessor get/set/dir/
repr/Fehlerpfade, In-place-Mutation, Sync/Prune, units-View).
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 11 minor |
| Security | 17 high |
| CodeStyle | 2 minor |
🟢 Metrics 33 complexity · 0 duplication
Metric Results Complexity 33 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Zweiter von vier PRs zur Verbesserung von
sdata/sclass/dataframe.py— Spalten-Ergonomie. Strikt additiv (load-bearing API unverändert), lokale CI grün, 100 % Coverage.Neu
set_column(name, *, unit/label/description/ontology/required/dtype)— annotiert eine Spalte schreibdurchgängig aufcolumn_metadata; nur gesetzte Felder ändern sich, vorhandene Annotationen bleiben erhalten (überMetadata.set_attr). Warnt (nicht-brechend), wennnamekeine df-Spalte ist.get_column(name) -> Attribute(oderNone).col-Accessor (ColumnAccessor, gespiegelt vonAttrAccessorininteractive.py):df.col.weight/df.col["weight"]liefern das Spalten-Attribute(Tab-Completion via__dir__); Felder direkt mutierbar (df.col.weight.unit = "kg"). Zuweisungdf.col.x = ...wirft bewusstAttributeErrorund verweist aufset_column.column_units— Mapping{Spalte: Einheit}in df-Spaltenreihenfolge.Sync/Prune
_sync_column_metadata()imdf-Setter: ergänzt neue Spalten und entfernt Attribute zu nicht mehr vorhandenen Spalten (prune=Truebei Neuzuweisung); vorhandeneunit/labelüberlebende Spalten bleiben erhalten.column_metadatableibt unverändert (prune=False, nur Waisen-Warnung aus PR1) — kein Verlust expliziter Nutzereingaben.Tests
tests/test_sclass_dataframe_columns.py(set/get, Accessor get/set/dir/repr/Fehlerpfade, In-place-Mutation, Sync/Prune bei Neuzuweisung, units-View).Lokale CI grün (
ci/local-ci.sh);dataframe.pyundinteractive.py= 100 %, Projekt-Total = 100 % (486 passed, 9 optionale Skips).