-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
flower.py
67 lines (48 loc) · 1.58 KB
/
flower.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
import marimo
__generated_with = "0.8.15"
app = marimo.App(width="medium")
@app.cell
def __():
import marimo as mo
import polars as pl
import quak
return mo, pl, quak
@app.cell
def __(mo, pl, quak):
df = pl.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv")
widget_quack = mo.ui.anywidget(quak.Widget(df))
widget_quack
return df, widget_quack
@app.cell
def __(mo):
from tldraw import FlowerPlot
flower_data = [
{"sepal_length": 5.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.4},
{"sepal_length": 4.9, "sepal_width": 3.0, "petal_length": 1.4, "petal_width": 0.2},
]
widget_flower = mo.ui.anywidget(FlowerPlot(flower_data=flower_data))
widget_flower
return FlowerPlot, flower_data, widget_flower
@app.cell
def __(widget_flower, widget_quack):
widget_df = widget_quack.data().pl()
#print(widget_df.select(["petal_length", "petal_width"]))
df_selected = widget_df.select(
["sepal_length", "sepal_width", "petal_length", "petal_width"]
)
print(df_selected.to_dicts())
# Convert the selected dataframe to a list of dictionaries
widget_flower.flower_data = df_selected.to_dicts()
return df_selected, widget_df
@app.cell
def __(widget_flower):
widget_flower.flower_data = [
{"sepal_length": 20.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.4},
{"sepal_length": 4.9, "sepal_width": 3.0, "petal_length": 1.4, "petal_width": 0.2},
]
return
@app.cell
def __():
return
if __name__ == "__main__":
app.run()