I have a Pandas Dataframe named Merged
that has an attribute named RegimentalNumber
.
I'm using the Pandas.Dataframe.duplicated()
method to retrieve the duplicates from this dataframe like so:
In [16]: Merged[Merged.RegimentalNumber.duplicated() == True]
However, it looks like the result also includes missing values of RegimentalNumber
as duplicates.
Does the duplicated()
method take a flag or parameter to exclude missing values as duplicates? I took a look at the API Documentation for this method but could not find such a flag.
Of course I can then simply exclude the missing values like this:
In [17]: duplicates = Merged[Merged.RegimentalNumber.duplicated() == True]
In [18]: duplicates[duplicates.RegimentalNumber.notnull()]
However, it doesn't seem right to me that the duplicated()
method also includes missing values as duplicates. Is there a simpler, one step solution?