@@ -87,33 +87,36 @@ def wrapper(*args, **kwargs):
87
87
88
88
89
89
@app .cell
90
- def create_comparison_plot (pandas_time , polars_time , title ):
90
+ def create_comparison_plot ():
91
91
import matplotlib .pyplot as plt
92
92
import seaborn as sns
93
93
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 ,)
117
120
118
121
119
122
@app .cell (hide_code = True )
@@ -145,7 +148,7 @@ def read_polars():
145
148
146
149
147
150
@app .cell
148
- def _ (pandas_read_time , polars_read_time ):
151
+ def _ (create_comparison_plot , pandas_read_time , polars_read_time ):
149
152
create_comparison_plot (pandas_read_time , polars_read_time , "CSV Read Time" )
150
153
return
151
154
@@ -177,7 +180,7 @@ def polars_groupby(df):
177
180
178
181
179
182
@app .cell
180
- def _ (pandas_groupby_time , polars_groupby_time ):
183
+ def _ (create_comparison_plot , pandas_groupby_time , polars_groupby_time ):
181
184
create_comparison_plot (
182
185
pandas_groupby_time , polars_groupby_time , "Groupby Mean Time"
183
186
)
@@ -211,7 +214,7 @@ def polars_filter(df):
211
214
212
215
213
216
@app .cell
214
- def _ (pandas_filter_time , polars_filter_time ):
217
+ def _ (create_comparison_plot , pandas_filter_time , polars_filter_time ):
215
218
create_comparison_plot (pandas_filter_time , polars_filter_time , "Filter Rows Time" )
216
219
return
217
220
@@ -243,7 +246,7 @@ def polars_sort(df):
243
246
244
247
245
248
@app .cell
246
- def _ (pandas_sort_time , polars_sort_time ):
249
+ def _ (create_comparison_plot , pandas_sort_time , polars_sort_time ):
247
250
create_comparison_plot (pandas_sort_time , polars_sort_time , "Sort Time" )
248
251
return
249
252
0 commit comments