DRY DataFrameModel fields #1497
Unanswered
lundybernard
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Given many data fields from various sources (raw input, computed, normalized, etc),
I need to create many DataFrameModels, composed of different sets of these fields.
I want to re-use field/column/DataFrameModel definitions to DRYup the code as much as possible.
I have had some success re-using DataFrameModels:
Config
sub-classesHowever, this approach breaks down if I try to build intermediate collections of fields
This breaks down due to the classic diamond-shaped MRO problem
I have attempted to refactor the code using Mixin classes, the standard solution to this problem, but that approach breaks the
.to_schema()
method.This breaks at this point, even before we get to nested collections of fields.
Before delving any deeper into the inner-workings of
_collect_fields
I wanted to stop and ask for advice.What is the best, most pythonic, most Pandera'ic, way to create DRY, structured, DataFrameModels like this?
Primary concerns:
.strategy()
workingBeta Was this translation helpful? Give feedback.
All reactions