File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010)
1111import xlsxwriter # type: ignore [import-untyped]
1212
13+
1314# Deals with list columns data that CSV cannot deal with.
1415def _stringify_list_columns (df : pl .DataFrame ) -> pl .DataFrame :
1516 """Convert any List-type columns to JSON strings so CSV/Excel can handle them."""
1617 list_cols = [col for col , dtype in zip (df .columns , df .dtypes ) if dtype .base_type () == pl .List ]
1718 if list_cols :
1819 df = df .with_columns (
19- [pl .col (c ).map_elements (lambda val : json .dumps (val .to_list (), default = str ), return_dtype = pl .String ).alias (c ) for c in list_cols ]
20+ [
21+ pl .col (c )
22+ .map_elements (lambda val : json .dumps (val .to_list (), default = str ), return_dtype = pl .String )
23+ .alias (c )
24+ for c in list_cols
25+ ]
2026 )
2127 return df
2228
29+
2330def export_to_file (
2431 facilities_data : dict ,
2532 filename : str = "ice_detention_facilities_enriched" ,
You can’t perform that action at this time.
0 commit comments