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

Support for multiple items received in a single field #148

Closed
astropenguin opened this issue Dec 21, 2022 · 0 comments · Fixed by #152
Closed

Support for multiple items received in a single field #148

astropenguin opened this issue Dec 21, 2022 · 0 comments · Fixed by #152
Assignees
Labels
feature New feature or request
Milestone

Comments

@astropenguin
Copy link
Owner

astropenguin commented Dec 21, 2022

This issue will introduce a new type hint, Multiple[T], an alias of dict[str, T] with a dedicated tag, Tag.MULTIPLE. Combined with other type hints (e.g. Multiple[Data[Any]]), it will enable the corresponding field receive a dictionary of data, indexes, or attributes. For example, the attrs field in the following code will accept a dictionary of any values which will be stored in attrs in a DataFrame.

from dataclasses import dataclass, field
from pandas_dataclasses import AsFrame, Attr, Data, Index, Multiple


@dataclass
class Weather(AsFrame):
    """Weather information."""

    year: Index[int]
    month: Index[int]
    temp: Data[float]
    wind: Data[float]
    attrs: Multiple[Attr[Any]] = field(default_factory=dict)
@astropenguin astropenguin added the feature New feature or request label Dec 21, 2022
@astropenguin astropenguin added this to the v0.12 milestone Dec 21, 2022
@astropenguin astropenguin self-assigned this Dec 21, 2022
astropenguin added a commit that referenced this issue Jan 7, 2023
astropenguin added a commit that referenced this issue Jan 7, 2023
astropenguin added a commit that referenced this issue Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant