The D3Blocks library also contains various helper functions to get the data in the right shape for the desired chart.

vec2adjmat

Convert source and target into adjacency matrix.

param source:

The source node.

type source:

list

param target:

The target node.

type target:

list

param weight:

The Weights between the source-target values

type weight:

list of int

param symmetric:

Make the adjacency matrix symmetric with the same number of rows as columns. The default is True.

type symmetric:

bool, optional

param aggfunc:
Aggregate function in case multiple values exists for the same relationship.
  • ‘sum’ (default)

type aggfunc:

str, optional

returns:

adjacency matrix.

rtype:

pd.DataFrame

Examples

>>> # Initialize
>>> d3 = D3Blocks()
>>> #
>>> # Load example
>>> df = d3.import_example('energy')
>>> #
>>> # Convert to adjmat
>>> adjmat = d3.vec2adjmat(df['source'], df['target'], df['weight'])

adjmat2vec

Convert adjacency matrix into vector with source and target.

param adjmat:

Adjacency matrix.

type adjmat:

pd.DataFrame()

param min_weight:

edges are returned with a minimum weight.

type min_weight:

float

returns:

nodes that are connected based on source and target

rtype:

pd.DataFrame()

Examples

>>> # Initialize
>>> d3 = D3Blocks()
>>> #
>>> # Load example
>>> df = d3.import_example('energy')
>>> Convert into adjmat
>>> adjmat = d3.vec2adjmat(df['source'], df['target'], df['weight'])
>>> #
>>> # Convert back to vector
>>> vector = d3.adjmat2vec(adjmat)

Examples

Import example dataset from github source.

Import one of the few datasets from github sourcek.

param data:
Example datasets:
  • “movingbubbles”

  • “random_time”

  • “timeseries”

  • “bigbang”

  • “southern_nebula_internet”

  • “climate”

  • “mnist”

  • “animals”

Datazets:
  • “energy”

  • “stormofswords”

  • “southern_nebula”

  • “cancer”

  • “breast_cancer”

  • “iris”

  • “occupancy”

type data:

str

param n:

Number of events (samples).

type n:

int, (default: 1000).

param c:

Number of classes.

type c:

int, (default: 100).

param date_start:
Start date.
  • “17-12-1903 00:00:00” : start date

type date_start:

str, (default: None)

param date_stop:
Stop date.
  • “17-12-1903 23:59:59” : Stop date

type date_stop:

str, (default: None)

returns:

Dataset containing mixed features.

rtype:

pd.DataFrame()

Saving Charts

Each d3block contains saving functionality to save your chart to a SVG image. The save functionality can be enabled by setting the `save_button=True` parameter. After setting the save_button parameter, the output HTML will contain a save button that can be used accordingly. In case you do not need the save button, disable it with `save_button=False`.