Skip to main content

Flow Python Client

Introducing the Flow Immersive Python Client – a convenient solution for pushing data from pandas to Flow. With this library, you can easily upload datasets and identify them using a unique title. If you upload a new dataset with the same title, it will create a new version of the same dataset.

Here's how to use it.

Import the necessary libraries:

import pandas as pd
from flowgl import Client

Create a sample pandas dataframe:

df = pd.DataFrame({
    'name': ['John', 'Jane', 'Joe'],
    'age': [30, 25, 40],
    'city': ['New York', 'San Francisco', 'Los Angeles']
})

Create an instance of the client with your Flow credentials:

client = Client(
    username=...,
    password=...,
)

Push the dataframe to Flow by title:

client.push_data(
    df,
    dataset_title='My Dataset',
)

If you have a dictionary of nodes and edges, you can use the push_nodes_and_edges_dict method. This method requires you to specify the nodes and edges lists in the provided dictionary using jsonpath. Here's an example:

my_dict = {
    'nested_object': {
        'nodes': [
            {'id': 1, 'name': 'John'},
            {'id': 2, 'name': 'Jane'},
            {'id': 3, 'name': 'Joe'},
        ],
        'edges': [
            {'source': 1, 'target': 2},
            {'source': 2, 'target': 3},
        ]
    }
}

client.push_nodes_and_edges_dict(
    my_dict,
    nodes_jsonpath='$.nested_object.nodes',
    edges_jsonpath='$.nested_object.edges',
    dataset_title='My Dataset',
)

With the Flow Immersive Python Client, it's easier than ever to push data from pandas to Flow, whether it be in the form of a pandas DataFrame or a dictionary of nodes and edges. With its user-friendly methods, you can quickly and easily upload your data to Flow, identify it with a title, and create new dataset versions if needed. The code examples provided in this blog post give you a good starting point for using the Flow Immersive Python Client in your own projects.

In conclusion, the Flow Immersive Python Client offers a simple and efficient solution for pushing data from pandas to Flow, making it a valuable tool for anyone looking to streamline their data management process.