drop_duplicates() doesn't work in pandas [closed]

I am working on my pandas tutorial. Below is my dataframe

I am trying to drop duplicated header row using

df_FDNY_dataset.drop_duplicates(subset=['FacilityName','FacilityAddress','Borough'])


But drop_duplicates() function doesn't work in this case. Could you help me understand the same.

Thanks.

• Where is the duplication?? – Aditya Feb 23 '18 at 6:41
• Just a comment that you could easily find this by 5-min searching/googling and no need to ask here! And always to keep in mind that it is best practice to provide a working data (even tiny) to allow people to reproduce your problem fast. Here is easy, but there are cases that a snapshot won't help! Happy learning. – TwinPenguins Feb 23 '18 at 7:43

So basically you want to drop the 1st row, which is indexed as 0 in the DataFrame.

This can be done by

df.drop(df.index[0], inplace = True)


The header row is not duplicated, it is a row of the data frame (see index 0 attached with it, The actual columns don't have any index number). That's why you can't remove it using drop_duplicates. If you want to remove it after having it in data frame, then

df = df.iloc[1:,:]


where df is your data frame.