Skip to main content

Processing Nodes and Edges with Python and Flow API

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, whether it be in the form of a pandas DataFrame or a dictionary of nodes and edges.