Python Forum
How to find index of a particular value in a dataframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to find index of a particular value in a dataframe
#1
Hi,
I need to find index of a particular value in a dataframe.

for ata9 in ATA9_list:
ATA_Data = data[data['ATA9'] == ata9]
if len(ATA_Data) > 1:
for i in range(len(ATA_Data)-1):
#comparing values in the row 0 and row 1 when i=0 and subsequently till len-1
if (((ATA_Data.iloc[i+1,1] - ATA_Data.iloc[i,1]).days <= 90) and (ATA_Data.iloc[i+1,4] != ATA_Data.iloc[i,4])):
repeat_index = ATA_Data.iloc[i+1,4].index

-- I need to know index of the element which is at position ATA_Data.iloc[i+1,4], which is an int value. This gives me error saying : 'numpy.int64' object has no attribute 'index'
if I use the following :
repeat_index = ATA_Data[data['Miles']==data.iloc[i+1,4]].index.tolist()

It gives me all indexes, not just the repeated ones.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Getting Index Error - list index out of range krishna 2 2,568 Jan-09-2021, 08:29 AM
Last Post: buran
  Interpolating DataFrame method=‘index’ help tlewick1 1 1,822 Oct-22-2020, 12:48 AM
Last Post: scidam
  Getting Index Error - list index out of range RahulSingh 2 6,102 Feb-03-2020, 07:17 AM
Last Post: RahulSingh
  How to add data to the categorical index of dataframe as data arrives? AlekseyPython 1 2,317 Oct-16-2019, 06:26 AM
Last Post: AlekseyPython
  Applying operation to a pandas multi index dataframe subgroup Nuovoq 1 2,620 Sep-04-2019, 10:04 PM
Last Post: Nuovoq
  How to find difference between two timestamp index python_newbie09 3 4,179 Aug-01-2019, 10:24 AM
Last Post: python_newbie09
  How to get first and last row index of each unique names in pandas dataframe SriRajesh 1 4,453 Oct-13-2018, 07:04 AM
Last Post: perfringo
  DataFrame index issue Astrikor 2 3,001 Aug-25-2018, 04:25 PM
Last Post: Astrikor
  How to find column index and its corresponding column name Raj 2 3,380 May-10-2018, 12:30 PM
Last Post: volcano63
  Newbie question to return only the index of a dataframe zydjohn 0 2,522 Jan-22-2018, 03:40 PM
Last Post: zydjohn

Forum Jump:

User Panel Messages

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