-3
$\begingroup$

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

enter image description here

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.

$\endgroup$
2
  • 1
    $\begingroup$ Where is the duplication?? $\endgroup$
    – Aditya
    Commented Feb 23, 2018 at 6:41
  • $\begingroup$ 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. $\endgroup$ Commented Feb 23, 2018 at 7:43

2 Answers 2

2
$\begingroup$

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)
$\endgroup$
0
1
$\begingroup$

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.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.