Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

How to implement a table in Python with json type data in Plotly using the “json” module?

Here is my code using Pandas:

import plotly.graph_objects as go
import pandas as pd

iris_data = pd.read_json("iris.json")

fig = go.Figure(data=[go.Table(
    cells=dict(values=[iris_data.UserName, iris_data.Email, iris_data.IP, iris_data.DataDołączenia, iris_data.LiczbaUrządzeń, iris_data.CzyAdmin],

It works nicely, but it is very important that I use the standard “json” python module instead of Pandas here. How can I do that?

This seems to be a course assignment.

Is this the classical iris data set used in ML?
To get help you must give the structure of your json file. Here there is a version of iris data set in json format, which consists in a list of dicts:

I read it as follows:

import json
with open('iris.json', 'r') as fp:
    jdata = json.load( fp)
print(type(jdata))  #it is list

Let us print the first list element:

It displays:

{'sepalLength': 5.1,
 'sepalWidth': 3.5,
 'petalLength': 1.4,
 'petalWidth': 0.2,
 'species': 'setosa'}

while jadata[100] is the dict:

{'sepalLength': 6.3,
 'sepalWidth': 3.3,
 'petalLength': 6.0,
 'petalWidth': 2.5,
 'species': 'virginica'}

Hence you must read your particular json file, and depending on its structure you have to extract information to
define each table row.