Python Forum
How to get first and last row index of each unique names in pandas dataframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get first and last row index of each unique names in pandas dataframe
#1
I am very new to python, I want to get the first and last row index of each unique elements based on the 2nd column.
MUY09KT00    TW00.00
MUY09KT00    TW00.00
MUY09KT00    TW00.00
MHJ09KT00    PW00.00
MHJ09KT00    PW00.00
LHJ09KT00    NPW00.00
LHJ09KT00    NPW00.00
LHJ09KT00    NPW00.00
in this case, the unique element first index are:
1
4
6
in this case, the unique element last index are:
3
5
8
Reply


Messages In This Thread
How to get first and last row index of each unique names in pandas dataframe - by SriRajesh - Oct-12-2018, 12:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Add NER output to pandas dataframe dg3000 0 119 Apr-22-2024, 08:14 PM
Last Post: dg3000
  Grouping in pandas/multi-index data frame Aleqsie 3 695 Jan-06-2024, 03:55 PM
Last Post: deanhystad
  HTML Decoder pandas dataframe column mbrown009 3 1,061 Sep-29-2023, 05:56 PM
Last Post: deanhystad
  Use pandas to obtain cartesian product between a dataframe of int and equations? haihal 0 1,131 Jan-06-2023, 10:53 PM
Last Post: haihal
  Separating unique, stable, samples using pandas keithpfio 1 1,120 Jun-20-2022, 07:06 PM
Last Post: keithpfio
  Pandas Dataframe Filtering based on rows mvdlm 0 1,449 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  Pandas dataframe: calculate metrics by year mcva 1 2,329 Mar-02-2022, 08:22 AM
Last Post: mcva
  Pandas dataframe comparing anto5 0 1,273 Jan-30-2022, 10:21 AM
Last Post: anto5
  PANDAS: DataFrame | Replace and others questions moduki1 2 1,810 Jan-10-2022, 07:19 PM
Last Post: moduki1
  PANDAS: DataFrame | Saving the wrong value moduki1 0 1,559 Jan-10-2022, 04:42 PM
Last Post: moduki1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020