Pandas: How Do I Loop Through And Remove Rows Where A Column Has A Single Entry
So I have a pandas dataframe with some number of columns (Below is the code for a simple dataframe but the real dataframe has over 100 columns): X = pd.DataFrame([['A','Z'],['A','Z
Solution 1:
You can use duplicated as so:
X = pd.DataFrame([["A","Z"],["A","Z"],["B","Z"], ["A","Y"]],columns=["COL1","COL2"])
forcolumnin X:
X = X[X[column].duplicated(keep=False)]
Output:
COL1 COL2
0A Z
1A Z
Post a Comment for "Pandas: How Do I Loop Through And Remove Rows Where A Column Has A Single Entry"