Skip to main content

Flow Python Client

This article is one of the Integration features supported by Flow. See also: Using Flow Datasets Integrations

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.

Our python library is available on PyPi. Start by installing it with pip:

pip install flowgl

Here's a short script pushing an example pandas DataFrame to a dataset titled 'My Dataset'.

# 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="flow immersive username",
    password="flow immersive password",
)

# Push the dataframe to Flow by defining a title:
client.push_data(
    df,
    dataset_title='Test',
)

If the title doesn't yet exist for your user, a dataset will be created. If the title exists, a new version will be created.

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': [
            {'key': 1, 'name': 'John'},
            {'key': 2, 'name': 'Jane'},
            {'key': 3, 'name': 'Joe'},
        ],
        'edges': [
            {'src': 1, 'dest': 2},
            {'src': 2, 'dest': 3},
        ]
    }
}

client.push_nodes_and_edges_dict(
    my_dict,
    nodes_jsonpath='$.nested_object.nodes',
    edges_jsonpath='$.nested_object.edges',
    node_id_key='key',
    edge_source_key='src',
    edge_target_key='dest',
    dataset_title='My Dataset',
)

With the Flow Immersive Python Client, it's easier than ever to push data from pandas to Flow. 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.

See also: Using Flow Datasets Integrations