Skip to content
  • View menu
  • View sidebar

bioinfo core

Index & solution of bioInfo utilities

  • Home
  • All entries
  • Blogs
  • Contact
  • About

Categories

  • Between languages (7)
  • Blogs (8)
  • Python (35)
  • R (1)
  • Unix (37)

Tags

bedfile Blogs conda Excel html numpy Pandas Python R slurm Unix
05/28/202010/21/2021 by bioinfocore

Python Pandas remove rows with the same index

  • Python
  • Pandas, Python

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')]

Source:
https://stackoverflow.com/questions/13035764/remove-rows-with-duplicate-indices-pandas-dataframe-and-timeseries

Post navigation

← Previous Post Unix insert a line to the beginning of a file
Next Post → Run Unix commands in python
Copyright 2024 | by bioinfocore