etrotta commited on
Commit
caac288
·
1 Parent(s): e2447fe

Try to fix run all again. Failed again.

Browse files
Files changed (1) hide show
  1. polars/05_reactive_plots.py +23 -12
polars/05_reactive_plots.py CHANGED
@@ -11,7 +11,7 @@
11
 
12
  import marimo
13
 
14
- __generated_with = "0.11.14"
15
  app = marimo.App(width="medium")
16
 
17
 
@@ -41,13 +41,17 @@ def _(mo):
41
 
42
  @app.cell
43
  def _(pl):
44
- repo_id, branch, file_path = (
45
- "maharshipandya/spotify-tracks-dataset",
46
- "~parquet",
47
- "default/train/0000.parquet",
48
- )
49
- URL = f"hf://datasets/{repo_id}@{branch}/{file_path}"
50
- lz = pl.scan_parquet(URL)
 
 
 
 
51
  df = (
52
  lz
53
  # Filter data we consider relevant (somewhat arbitrary in this example)
@@ -66,7 +70,7 @@ def _(pl):
66
  .collect()
67
  )
68
  df
69
- return URL, branch, df, file_path, lz, repo_id
70
 
71
 
72
  @app.cell(hide_code=True)
@@ -361,10 +365,17 @@ def _(filtered_duration, mo, pl):
361
  # Note that we cannot use dropdown due to the sheer number of elements being enormous:
362
  all_artists = filtered_duration.select(pl.col("artists").str.split(';').explode().unique().sort())['artists'].to_list()
363
  all_tracks = filtered_duration['track_name'].unique().sort().to_list()
364
- filter_artist = mo.ui.dropdown(all_artists, value=None, searchable=True)
365
- filter_track = mo.ui.dropdown(all_tracks, value=None, searchable=True)
366
  # So we just provide freeform text boxes and filter ourselfves later
367
- return all_artists, all_tracks, filter_artist, filter_track
 
 
 
 
 
 
 
368
 
369
 
370
  @app.cell
 
11
 
12
  import marimo
13
 
14
+ __generated_with = "0.11.16"
15
  app = marimo.App(width="medium")
16
 
17
 
 
41
 
42
  @app.cell
43
  def _(pl):
44
+ # You can read directly from the Hugging Face dataset, in which case polars will only read the necessary data:
45
+ #repo_id, branch, file_path = (
46
+ # "maharshipandya/spotify-tracks-dataset",
47
+ # "~parquet",
48
+ # "default/train/0000.parquet",
49
+ #)
50
+ #URL = f"hf://datasets/{repo_id}@{branch}/{file_path}"
51
+ #lz = pl.scan_parquet(URL)
52
+ # Or save to a local file first if you want to avoid downloading it each time you run:
53
+ file_path = "spotify-tracks.parquet"
54
+ lz = pl.scan_parquet(file_path)
55
  df = (
56
  lz
57
  # Filter data we consider relevant (somewhat arbitrary in this example)
 
70
  .collect()
71
  )
72
  df
73
+ return df, file_path, lz
74
 
75
 
76
  @app.cell(hide_code=True)
 
365
  # Note that we cannot use dropdown due to the sheer number of elements being enormous:
366
  all_artists = filtered_duration.select(pl.col("artists").str.split(';').explode().unique().sort())['artists'].to_list()
367
  all_tracks = filtered_duration['track_name'].unique().sort().to_list()
368
+ alternative_filter_artist = mo.ui.dropdown(all_artists, value=None, searchable=True)
369
+ alternative_filter_track = mo.ui.dropdown(all_tracks, value=None, searchable=True)
370
  # So we just provide freeform text boxes and filter ourselfves later
371
+ # (the "alternative_" in the name is just to avoid conflicts with the above cell,
372
+ # despite this being disabled marimo still requires global variables to be unique)
373
+ return (
374
+ all_artists,
375
+ all_tracks,
376
+ alternative_filter_artist,
377
+ alternative_filter_track,
378
+ )
379
 
380
 
381
  @app.cell