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

guarantee record type invariance? #3

Open
mphelp opened this issue Dec 23, 2020 · 1 comment
Open

guarantee record type invariance? #3

mphelp opened this issue Dec 23, 2020 · 1 comment

Comments

@mphelp
Copy link

mphelp commented Dec 23, 2020

@joshlk

This package provides an effective way to create pandas dataframes from data that fits a dataclass. Thanks for writing it.

I saw this comment which echoed something I thought too: https://github.com/joshlk/dataclassframe/blob/main/dataclassframe/dataclassframe_.py#L93

i.e. should the underlying dataframe records type/schema always be the exact same dataclass? I tried the package myself and can easily add a column to the dataframe when using dataclassframe.

My suggestion would be to either force this behavior OR provide an optional "record_class_frozen" to the DataClassFrame constructor.

NOTE: I know in general python doesn’t have runtime type checking, so I’m not sure how this would be enforced

@joshlk
Copy link
Owner

joshlk commented Dec 29, 2020

Hi @mphelp,

Thanks for your interest in the project 😃.

One of the main principles of the DataClassFrame is that it's column wise immutable i.e. the schema should not change including the type. So I would like to enforce this as much as possible.

Currently it's quite easy to break this principle by manipulating the underlying DataFrame data (the .df attribute) but there is no way I can prevent that. Could you provide some examples of how you changed the schema of a DataClassFrame?

Thanks again for your interest,
Josh

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

No branches or pull requests

2 participants