Jan-21-2020, 09:45 PM
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.
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.