Skip to main content

Graphene Pandas integration

Project description

Build Status Coverage Status

graphene-pandas(under developing)

Installation

For instaling graphene-pandas, just run this command in your shell

pip3 install graphene-pandas(not implemented)

Examples

To create a GraphQL schema for it, you simply have to write the following:

import pandas as pd

import graphene
from graphene_pandas import DataFrameObjectType

data = {"Brand": ["Honda Civic", "Toyota Corolla", "Ford Focus", "Audi A4"],
        "Price": [22000, 25000, 27000, 35000]}
df = pd.DataFrame(data)


class Records(DataFrameObjectType):
    class Meta:
        model = df
        exclude_fields = ()


class Query(graphene.ObjectType):
    record = graphene.Field(Records, index=graphene.Int())
    records = graphene.List(Records)

    def resolve_record(self, info, index):
        query = Records.get_row_int_index(info, index)
        return query

    def resolve_records(self, info):
        query = Records.get_all_rows(info)
        return query

schema = graphene.Schema(query=Query)

query = """
            query Test {
              record(index: 1) {
                Brand
                Price
              }
              records {
                Brand
                Price
              }
            }
        """

result = graphene.schema.execute(query)


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

graphene-pandas-0.1.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

graphene_pandas-0.1.1-py2.py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 2 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