Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically create a DataFrameModel #1514

Open
tjboller opened this issue Feb 24, 2024 · 0 comments
Open

Dynamically create a DataFrameModel #1514

tjboller opened this issue Feb 24, 2024 · 0 comments
Labels
question Further information is requested

Comments

@tjboller
Copy link

I much prefer DataFrameModel over DataFrameSchema for a few reasons:

I like being able to do type hinting as well as being able to dynamically access the column names so hard coding strings is a thing of the past

for example:

def foo(df: pa.DataFrame[MyDataFrameModel]) -> float:
    return df[MyDataFrameModel.my_column].mean()

However, often I cant make a DataFrameModel if the output schema depends on some runtime parameters - and thus forced to use DataFrameSchema but sadly cant use the nice features in the function above (as far as im aware).

Does anyone any workarounds?

Something like https://docs.python.org/3/library/dataclasses.html#dataclasses.make_dataclass?

@tjboller tjboller added the question Further information is requested label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant