Skip to content

Instantly share code, notes, and snippets.

@thomascamminady
Created September 20, 2023 07:40
Show Gist options
  • Save thomascamminady/dbfb8f751eb41acbf2dc95608bc3e99a to your computer and use it in GitHub Desktop.
Save thomascamminady/dbfb8f751eb41acbf2dc95608bc3e99a to your computer and use it in GitHub Desktop.
Polars drop columns that are all null
import polars as pl
def drop_columns_that_are_all_null(_df: pl.DataFrame) -> pl.DataFrame:
return _df[[s.name for s in _df if not (s.null_count() == _df.height)]]
# df.pipe(drop_columns_that_are_all_null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment