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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file beardataclass-0.2.1.tar.gz.
File metadata
- Download URL: beardataclass-0.2.1.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.12.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acdb317771aaf470368aee200bf2aa9596199b476cd0692576c90d20b8018ad8
|
|
| MD5 |
f5f6de612efe803857303c0cd14c5363
|
|
| BLAKE2b-256 |
f177dccf91f79c396a932e36831715395e30bdecfb49c3651980eb01c4354e1d
|
File details
Details for the file beardataclass-0.2.1-py3-none-any.whl.
File metadata
- Download URL: beardataclass-0.2.1-py3-none-any.whl
- Upload date:
- Size: 2.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.12.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2062351e592159bd1f3e9888973a8a375f8d25bba371592dd2f040f7aadbcbab
|
|
| MD5 |
140263dbb8ab2be0a315adce1d71039d
|
|
| BLAKE2b-256 |
ea1a853f19ed1ce9369e82d028161b3f355013a505303948388095ef181964e4
|