Skip to main content

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


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 details)

Uploaded Source

Built Distribution

beardataclass-0.2.1-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

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

Hashes for beardataclass-0.2.1.tar.gz
Algorithm Hash digest
SHA256 acdb317771aaf470368aee200bf2aa9596199b476cd0692576c90d20b8018ad8
MD5 f5f6de612efe803857303c0cd14c5363
BLAKE2b-256 f177dccf91f79c396a932e36831715395e30bdecfb49c3651980eb01c4354e1d

See more details on using hashes here.

File details

Details for the file beardataclass-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for beardataclass-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2062351e592159bd1f3e9888973a8a375f8d25bba371592dd2f040f7aadbcbab
MD5 140263dbb8ab2be0a315adce1d71039d
BLAKE2b-256 ea1a853f19ed1ce9369e82d028161b3f355013a505303948388095ef181964e4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page