Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python - Drop row if two columns are NaN

df.dropna(subset=[1, 2], how='all')
Or
df.dropna(subset=[1, 2], thresh=1)
Comment

pandas drop rows with nan in a particular column

In [30]: df.dropna(subset=[1])   #Drop only if NaN in specific column (as asked in the question)
Out[30]:
          0         1         2
1  2.677677 -1.466923 -0.750366
2       NaN  0.798002 -0.906038
3  0.672201  0.964789       NaN
5 -1.250970  0.030561 -2.678622
6       NaN  1.036043       NaN
7  0.049896 -0.308003  0.823295
9 -0.310130  0.078891       NaN
Comment

PREVIOUS NEXT
Code Example
Python :: python remove a key from a dictionary 
Python :: use python type hint for multiple return values 
Python :: median in python 
Python :: parameter grid 
Python :: sort by dataframe 
Python :: powershell get list of groups and members 
Python :: panda datetime ymd to dmy 
Python :: convert any base to decimal python 
Python :: python delete key from dict 
Python :: print the number of times that the substring occurs in the given string 
Python :: How to perform insertion sort, in Python? 
Python :: remove last element from dictionary python 
Python :: python [a]*b means [a,a,...b times] v2 
Python :: python inspect source code 
Python :: python logging to file 
Python :: round godot 
Python :: get string between two characters python 
Python :: python count distinct letters 
Python :: how to check if mouse is over a rect in pygame 
Python :: pandas replace column name from a dictionary 
Python :: python df round values 
Python :: python print int in string with zero padding 
Python :: athena connector python 
Python :: binary search tree iterator python 
Python :: python enumerate start at 1 
Python :: how to input 2-d array in python 
Python :: seaborn heatmap parameters 
Python :: discord.py cog 
Python :: confusion matrix python code 
Python :: remove emoji from dataframe 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =