BearDataClass
Problem
A dataframe (in pandas or polars) often simply represents a collection of dataclass instances. However, we cannot access the new dataframe using dataclass attributes.
Solution (How to use)
This package proposes the simple BearDataClass Mixin-class. Dataclasses inheriting from it come with a few convenience methods to operate on dataframes based on dataclasses:
from dataclasses import dataclass
from beardataclass import BearDataClass
@dataclass
class Foo(BearDataClass):
x: int
df = Foo.create_pandas_df([Foo(1), Foo(2)])
df.loc[:, Foo.fields().x] *= 2
recreated = Foo.from_row(df.iloc[0,:])
How to install
Run pip install BearDataClass
Release files for BearDataClass 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| beardataclass-0.2.1.tar.gz | 2.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| beardataclass-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.6 kB
Release files / beardataclass-0.2.1.tar.gz
| Download URL | beardataclass-0.2.1.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
acdb317771aaf470368aee200bf2aa9596199b476cd0692576c90d20b8018ad8
|
|
BLAKE2b-256 checksum How to use checksums |
f177dccf91f79c396a932e36831715395e30bdecfb49c3651980eb01c4354e1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.12.2 CPython/3.10.12
|
Release files / beardataclass-0.2.1-py3-none-any.whl
| Download URL | beardataclass-0.2.1-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2062351e592159bd1f3e9888973a8a375f8d25bba371592dd2f040f7aadbcbab
|
|
BLAKE2b-256 checksum How to use checksums |
ea1a853f19ed1ce9369e82d028161b3f355013a505303948388095ef181964e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.12.2 CPython/3.10.12
|