If you are not using DataFrames, you can manually construct data using several methods:
1. Specify data by series
Use add_series(name, values, type="dimension" | "measure") to add columns one by one.
2. Specify data by records
Use add_record(list) for a single row, or add_records(list_of_lists | list_of_dicts) for multiple rows. Records must be in first normal form.
3. Using data cube form
This is useful for dense data where you define dimensions and then a matrix of measures.
- Use
add_dimension(name, values) for each dimension. - Use
add_measure(name, matrix) where the matrix is a list of lists representing the values for each combination of dimensions.
4. Using JSON
Load data directly from a JSON file using the class method Data.from_json(path).
from ipyvizzu import Data
# Data Cube Example
data = Data()
data.add_dimension("Genres", ["Pop", "Rock"])
data.add_dimension("Kinds", ["Hard", "Smooth"])
data.add_measure("Popularity", [[114, 96], [56, 36]])
# JSON Example
data = Data.from_json("path/to/data.json")