gistlib
main.pyimport polars as pl # Create a dataframe df = pl.DataFrame( { "name_abc": ["Alice", "Bob", "Charlie"], "age_xyz": [25, 30, 35], "city_pqr": ["New York", "Los Angeles", "Chicago"] } ) # Select columns containing the string 'abc' in their headers selected_cols = [col for col in df.columns if 'abc' in col] # Subsetting the dataframe using the selected columns result = df.select(selected_cols) print(result) 443 chars19 lines
import polars as pl # Create a dataframe df = pl.DataFrame( { "name_abc": ["Alice", "Bob", "Charlie"], "age_xyz": [25, 30, 35], "city_pqr": ["New York", "Los Angeles", "Chicago"] } ) # Select columns containing the string 'abc' in their headers selected_cols = [col for col in df.columns if 'abc' in col] # Subsetting the dataframe using the selected columns result = df.select(selected_cols) print(result)
gistlibby LogSnag