No project description provided
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
beardataclass-0.2.1.tar.gz
(2.4 kB
view hashes)
Built Distribution
Close
Hashes for beardataclass-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2062351e592159bd1f3e9888973a8a375f8d25bba371592dd2f040f7aadbcbab |
|
MD5 | 140263dbb8ab2be0a315adce1d71039d |
|
BLAKE2b-256 | ea1a853f19ed1ce9369e82d028161b3f355013a505303948388095ef181964e4 |