Remove rows with the same index, only keep one first or last of them.
df = df.loc[~df.index.duplicated(keep='first')]
df = df.loc[~df.index.duplicated(keep='last')]
Remove rows with the same index, only keep one first or last of them.
df = df.loc[~df.index.duplicated(keep='first')]
df = df.loc[~df.index.duplicated(keep='last')]