@@ -87,33 +87,36 @@ def wrapper(*args, **kwargs):
8787
8888
8989@app .cell
90- def create_comparison_plot (pandas_time , polars_time , title ):
90+ def create_comparison_plot ():
9191 import matplotlib .pyplot as plt
9292 import seaborn as sns
9393
94- # Set style for this plot
95- sns .set (style = "whitegrid" )
96- plt .style .use ("dark_background" )
97- plt .rcParams .update (
98- {
99- "axes.facecolor" : "#2F2D2E" ,
100- "figure.facecolor" : "#2F2D2E" ,
101- "axes.labelcolor" : "white" ,
102- "xtick.color" : "white" ,
103- "ytick.color" : "white" ,
104- "text.color" : "white" ,
105- }
106- )
107-
108- # Create the plot
109- sns .barplot (
110- hue = ["Pandas" , "Polars" ],
111- y = [pandas_time , polars_time ],
112- palette = ["#E583B6" , "#72BEFA" ],
113- )
114- plt .title (f"{ title } (seconds)" )
115- plt .ylabel ("Time (s)" )
116- plt .show ()
94+ def create_comparison_plot (pandas_time , polars_time , title ):
95+ # Set style for this plot
96+ sns .set (style = "whitegrid" )
97+ plt .style .use ("dark_background" )
98+ plt .rcParams .update (
99+ {
100+ "axes.facecolor" : "#2F2D2E" ,
101+ "figure.facecolor" : "#2F2D2E" ,
102+ "axes.labelcolor" : "white" ,
103+ "xtick.color" : "white" ,
104+ "ytick.color" : "white" ,
105+ "text.color" : "white" ,
106+ }
107+ )
108+
109+ # Create the plot
110+ sns .barplot (
111+ hue = ["Pandas" , "Polars" ],
112+ y = [pandas_time , polars_time ],
113+ palette = ["#E583B6" , "#72BEFA" ],
114+ )
115+ plt .title (f"{ title } (seconds)" )
116+ plt .ylabel ("Time (s)" )
117+ plt .show ()
118+
119+ return (create_comparison_plot ,)
117120
118121
119122@app .cell (hide_code = True )
@@ -145,7 +148,7 @@ def read_polars():
145148
146149
147150@app .cell
148- def _ (pandas_read_time , polars_read_time ):
151+ def _ (create_comparison_plot , pandas_read_time , polars_read_time ):
149152 create_comparison_plot (pandas_read_time , polars_read_time , "CSV Read Time" )
150153 return
151154
@@ -177,7 +180,7 @@ def polars_groupby(df):
177180
178181
179182@app .cell
180- def _ (pandas_groupby_time , polars_groupby_time ):
183+ def _ (create_comparison_plot , pandas_groupby_time , polars_groupby_time ):
181184 create_comparison_plot (
182185 pandas_groupby_time , polars_groupby_time , "Groupby Mean Time"
183186 )
@@ -211,7 +214,7 @@ def polars_filter(df):
211214
212215
213216@app .cell
214- def _ (pandas_filter_time , polars_filter_time ):
217+ def _ (create_comparison_plot , pandas_filter_time , polars_filter_time ):
215218 create_comparison_plot (pandas_filter_time , polars_filter_time , "Filter Rows Time" )
216219 return
217220
@@ -243,7 +246,7 @@ def polars_sort(df):
243246
244247
245248@app .cell
246- def _ (pandas_sort_time , polars_sort_time ):
249+ def _ (create_comparison_plot , pandas_sort_time , polars_sort_time ):
247250 create_comparison_plot (pandas_sort_time , polars_sort_time , "Sort Time" )
248251 return
249252
0 commit comments