Closed HungryZebra563 closed 3 days ago
Thanks for the report! I can reproduce this on the 2.2.x branch but not on main. You've checked the box that you've verified this bug exists on the main branch of pandas. Can you confirm if you've done that?
Sorry, I'm an idiot. I forgot to activate the environment that had the dev install....
It is indeed fixed on the main branch, so I'll close the issue.
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
The value of index.has_duplicates of a subset of a dataframe depends on whether we run index.has_duplicates on the full dataframe first.
In the example,
df.iloc[0:1, :]
only has a single row, so it cannot have duplicates. The first call todf.iloc[0:1, :].index.has_duplicates
correctly returns False. However, after we queried the same property on the full dataframe,df.index.has_duplicates
, the exact same statement on the subset now returns True.Expected Behavior
I would expect
df.iloc[0:1, :]
to always return False. It has only 1 row, so it cannot have duplicates.Installed Versions