@@ -301,15 +301,17 @@ def _get_version_blobs(self, version: str = "latest") -> list:
301301 )
302302
303303 def get_dataframe (
304- self , output = "pandas" , version = "latest"
304+ self , output = "pandas" , version = "latest" , pl_lazy : bool = False
305305 ) -> pd .DataFrame | pl .DataFrame :
306306 """Get the data as a pandas or polars dataframe
307307
308308 Args:
309309 output (str, optional): the type of dataframe to return,
310- either 'pandas' or 'polars'. Defaults to "pandas".
310+ either 'pandas' or 'polars'. Defaults to "pandas".
311311 version (str, optional): the version of the data to get.
312- Defaults to "latest".
312+ Defaults to "latest".
313+ pl_lazy (bool, optional): whether to return a lazy polars dataframe.
314+ Defaults to False.
313315
314316 Raises:
315317 ValueError: if output is not 'pandas' or 'polars'
@@ -334,6 +336,8 @@ def get_dataframe(
334336 [pl .read_csv (blob ) for blob in blob_files ],
335337 how = "vertical_relaxed" ,
336338 )
339+ if pl_lazy :
340+ df = df .lazy ()
337341 return df
338342 elif file_ext == "json" :
339343 if output in ["pandas" , "pd" ]:
@@ -343,6 +347,8 @@ def get_dataframe(
343347 df = pl .concat (
344348 [pl .read_json (blob ) for blob in blob_files ],
345349 )
350+ if pl_lazy :
351+ df = df .lazy ()
346352 return df
347353 elif file_ext == "jsonl" :
348354 if output in ["pandas" , "pd" ]:
@@ -354,6 +360,8 @@ def get_dataframe(
354360 df = pl .concat (
355361 [pl .read_ndjson (blob ) for blob in blob_files ],
356362 )
363+ if pl_lazy :
364+ df = df .lazy ()
357365 return df
358366 elif file_ext == "parquet" or file_ext == "parq" :
359367 if output in ["pandas" , "pd" ]:
@@ -366,6 +374,8 @@ def get_dataframe(
366374 [pl .read_parquet (pq_file ) for pq_file in blob_files ],
367375 how = "vertical_relaxed" ,
368376 )
377+ if pl_lazy :
378+ df = df .lazy ()
369379 return df
370380
371381 def ledger_entry (self , action : str ) -> None :
0 commit comments