Created
September 20, 2023 07:40
-
-
Save thomascamminady/dbfb8f751eb41acbf2dc95608bc3e99a to your computer and use it in GitHub Desktop.
Polars drop columns that are all null
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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