Pandas DataFrame subclasses that enforce structure and can self-organize.
Project description
Typed DataFrames
Pandas DataFrame subclasses that enforce structure and can self-organize. Because your functions can’t exactly accept any DataFrame. See the docs for more information.
Simple example for a CSV like this:
key | value | note |
---|---|---|
abc | 123 | ? |
from typing import Sequence
from typeddfs import SimpleFrame, OrganizingFrame
class KeyValue(OrganizingFrame):
@classmethod
def required_index_names(cls) -> Sequence[str]:
return ['key']
@classmethod
def required_columns(cls) -> Sequence[str]:
return ['value']
@classmethod
def reserved_columns(cls) -> Sequence[str]:
return ['note']
# will self-organizing and use 'key' as the index
df = KeyValue.read_csv('example.csv')
print(df.index.names, list(df.columns)) # ['key'], ['value', 'note']
New issues and pull requests are welcome.
Please refer to the contributing guide.
Generated with Tyrannosaurus: tyrannosaurus new typed-dfs
.
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
typeddfs-0.1.0.tar.gz
(9.4 kB
view hashes)