1

I have the data series including these labels for my dataset:

s=['A','A','A','A','B','B','B','B','C','C','C','C','D','D','D','D','D']

I would like to know how can I get the index of first element B and the last element of C.

yatu
  • 86,083
  • 12
  • 84
  • 139
Sasa
  • 87
  • 8

1 Answers1

2

Index of the first element B

s.index('B')

Index of the last element C

len(s) - s[::-1].index('C') - 1
Kaies LAMIRI
  • 199
  • 1
  • 8