Q:

python remove element from list without changing index of other elements

I have a list L = [a,a,b,b,c,c] now I want to remove first 'b' so that the L becomes [a,a,b,c,c]. In the new L the index of first 'c' is 3. Is there any way I can remove first 'b' from L and still get the index of first 'c' as 4.
Thanks in advance.

A:

Perhaps you can get your desired effect with pandas:
>>> import pandas as pd
>>> L = ['a','a','b','b','c','c']
>>> df = pd.DataFrame(L)
>>> df
   0
0  a
1  a
2  b
3  b
4  c
5  c

[6 rows x 1 columns]
>>> df = df.drop(3)
>>> df
   0
0  a
1  a
2  b
4  c
5  c

[5 rows x 1 columns]
>>> df.loc[4]
0    c
Name: 4, dtype: object
>>> df.loc[5]
0    c
Name: 5, dtype: object

