To drop columns with all values having NaNs, we can use DataFrame.dropna()
method along with the axis
parameter set to 1 (since we want to drop columns). We set the how
parameter to 'all'
, which specifies that we only want to drop columns where all values are NaN.
Here's an example:
main.py290 chars13 lines
This will output:
main.py40 chars6 lines
As we can see, column B
was dropped since all its values were NaN.
gistlibby LogSnag