Skip to main content

Dataframe class to support complex types in Genomics. The goal is to not compete with Pandas but will be inter-operable at some point.

Project description

Project generated with PyScaffold

BiocFrame

BiocFrame provides a base Dataframe class, intended to be a flexible data structure compared to Pandas DataFrame This would be interoperable with pandas but will support usecases in genomics.

Install

Package is published to PyPI

pip install biocframe

Usage

Lets create a DataFrame from a dictionary

from biocframe import DataFrame

df = DataFrame(
    data = {
        "seqnames": [
            "chr1",
            "chr2",
            "chr2",
            "chr2",
            "chr1",
            "chr1",
            "chr3",
            "chr3",
            "chr3",
            "chr3",
        ]
        * 20,
        "starts": range(100, 300),
        "ends": range(110, 310),
        "strand": ["-", "+", "+", "*", "*", "+", "+", "+", "-", "-"] * 20,
        "score": range(0, 200),
        "GC": [random() for _ in range(10)] * 20,
    }
)

Access Properties

A couple of accessor methods/properties are available to access column names and dims

# find the dimensions
print(df.dims)

# get the column names
print(df.colnames)

Setters

Using the Pythonic way to set values

# set new column names
df.colnames = [... new colnames ...]
print(df.colnames)

# add or reassign columns

df["score"] = range(200, 400)

Slice the DataFrame

Currently slicing is only supported by indices. A future version may implement pandas query like operations.

sliced_df = df[3:7, 2:5]

For more use cases including subset, checkout the documentation

Note

This project has been set up using PyScaffold 4.3. For details and usage information on PyScaffold see https://pyscaffold.org/.

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

BiocFrame-0.1.tar.gz (22.5 kB view hashes)

Uploaded Source

Built Distribution

BiocFrame-0.1-py3-none-any.whl (6.2 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