Py.Cafe

mariobuikhuizen/

vizro-exploring-data-visualization

Exploring Vizro: Interactive Data Visualization

DocsPricing
  • 1MB
  • app.py
  • bla.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Vizro is an open-source toolkit for creating modular data visualization applications.
# check out https://github.com/mckinsey/vizro for more info about Vizro
# and checkout https://vizro.readthedocs.io/en/stable/ for documentation.

import vizro.plotly.express as px
from vizro import Vizro
import vizro.models as vm

df = px.data.iris()

import json

from pathlib import Path
import hashlib

def hash_file(path, algo="sha256", chunk_size=1024 * 1024):
    """
    Calculate a streaming hash of a file.

    Args:
        path (str | Path): Path to the file.
        algo (str): Hash algorithm name (e.g., 'md5', 'sha1', 'sha256', 'blake2b').
        chunk_size (int): Bytes per read (default 1 MiB).

    Returns:
        str: Hex digest of the file.
    """
    h = hashlib.new(algo)
    with open(Path(path), "rb") as f:
        for chunk in iter(lambda: f.read(chunk_size), b""):
            h.update(chunk)
    return h.hexdigest()

md5 = hash_file("fraudTrain.csv", "md5")
print(md5)

md52 = hash_file("bla.json", "md5")
print(md52)


with open('fraudTrain.csv', 'rb') as f: a = f.read(200)
with open('fraudTrain.csv', 'rb') as f: f.seek(-200, 2); b = f.read()


page = vm.Page(
    title="Vizro on PyCafe " ,
    layout=vm.Grid(grid=[[0, 1], [2, 2], [2, 2], [3, 3], [3, 3]], row_min_height="140px"),
    components=[
        vm.Card(
            text=f"""
                ### What is Vizro? {md5} 
                An open-source toolkit for creating modular data visualization applications.
                
                {md52}

                {a}

                {b}

                Rapidly self-serve the assembly of customized dashboards in minutes - without the need for advanced coding or design experience - to create flexible and scalable, Python-enabled data visualization applications."""
        ),
        vm.Card(
            text="""
                ### Github

                Checkout Vizro's GitHub page for further information and release notes. Contributions are always welcome!""",
            href="https://github.com/mckinsey/vizro",
        ),
        vm.Graph(id="scatter_chart", figure=px.scatter(df, x="sepal_length", y="petal_width", color="species")),
        vm.Graph(id="hist_chart", figure=px.histogram(df, x="sepal_width", color="species")),
    ],
    controls=[vm.Filter(column="species"), vm.Filter(column="petal_length"), vm.Filter(column="sepal_width")],
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()