Skip to main content

Pandas dataframes to DDF packages.

Project description

Frame2Package

A helper library for converting Pandas dataframes to DDF packages.

Usage

import pandas as pd
import io
from frame2package import Frame2Package

# Load some sample data

data = """area	year	age	education	distribution
Bahamas	2000	15+	Total	1.0
Fiji	1970	80+	Total	1.0
Gabon	2025	20--64	Under 15	0.0
Brunei Darussalam	2045	All	Total	1.0
Thailand	1985	15+	Upper Secondary	0.07
"""

df = pd.read_csv(io.StringIO(data), sep='\t')

# Specify all the concepts in the dataset
# as per the DDF data format specification.

concepts = [
    {
        'concept': 'area',
        'concept_type': 'entity_domain'
    },
    {
        'concept': 'year',
        'concept_type': 'time'
    },
    {
        'concept': 'age',
        'concept_type': 'string'
    },
    {
        'concept': 'education',
        'concept_type': 'entity_domain'
    },
    {
        'concept': 'distribution',
        'concept_type': 'measure'
    },
]

# Initialize a Frame2Package object
f2p = Frame2Package(data=df, concepts=concepts)

# Save the package
f2p.to_package('sample-dataset')

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

frame2package-0.0.1.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

frame2package-0.0.1-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

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