import pandas as pd
import numpy as np
print df
I'm a newbie, I used pandas to process an excel file. I have a data frame like bellow
DAT_KEY IP DATA
01-04-19 10.0.0.1 3298329
01-04-19 10.0.0.1 0
02-04-19 10.0.0.1 3298339
02-04-19 10.0.0.1 0
01-04-19 10.0.0.2 3233233
01-04-19 10.0.0.2 0
01-04-19 10.0.0.3 0
I only want to delete the row when having same IP and DAT_KEY
and DATA=0
. Don't want to delete row have DATA=0
, but DAT_KEY and IP unique.
My expected outcome:
DAT_KEY IP DATA
01-04-19 10.0.0.1 3298329
02-04-19 10.0.0.1 3298339
01-04-19 10.0.0.2 3233233
01-04-19 10.0.0.3 0
I try with drop duplicates but it not suitable with my case
df = df.drop_duplicates()