Drop Rows That Have Same Values As Column Names In Pandas
I want drop rows that have same values as column names in Pandas. I was thinking about making an nested array of my dataframe and looping trough that array and checking if nested a
Solution 1:
You can pass eq
, with any
(any cell contain columns name ) or all
(all cell for each contain the columns name)
df[~df.eq(df.columns).any(1)]
ColA ColB ColC
0 1 5 1
1 3 1 5
3 1 2 2
Post a Comment for "Drop Rows That Have Same Values As Column Names In Pandas"