Skip to content

[Feature Request] Dataset from a dataclass #14

@maxbrodin

Description

@maxbrodin

Would be nice to have a feature to define a Dataset using a dataclass as a source.

So, instead of

DUser = Dataset["id": int, "name": str]

def process1(data: DUser):
  pass

we can use a dataclass as a source for field names and types, like

@dataclass
class User:
  id: int
  name: str

def process1(data: Dataset[User]):
  pass

This can help to automatically update a list of fields based on the data class, and also might be useful in refactoring.
Can be used like

users = pd.DataFrame(
  [
    User(id=1, name="Sam"),
    User(id=2, name="Rhett")
  ]
)

process1(users)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions