>>> df = pd.DataFrame(list(a))
>>> df
char
0 a
1 b
2 c
3 d
4 e
5 f
6 g
7 h
>>> df[df['char']=='c'].index.tolist()[0]
2
>>>
第二种方法:
>>> pd.Index(df['char']).get_loc('c')
2
>>> df = pd.DataFrame(list(a))
>>> df
char
0 a
1 b
2 c
3 d
4 e
5 f
6 g
7 h
>>> df[df['char']=='c'].index.tolist()[0]
2
>>>
第二种方法:
>>> pd.Index(df['char']).get_loc('c')
2
本文标题:2021-03-17DataFrame查找元素索引
本文链接:https://www.haomeiwen.com/subject/mgjecltx.html
网友评论