我有一个像这样的pandas数据框:
0 1 2 \
0 NaN NaN NaN
1 CITI Pass-T... NaN NaN
2 NaN NaN NaN
3 Certificateholder Distribution Summary NaN NaN
4 Class CUSIP Record Date
5 A-1 25151EAA1 12/30/2016
6 A-2 25151EAB9 12/30/2016
7 A-3 25151EAC7 12/30/2016
8 A-4 25151EAD5 12/30/2016
9 A-5A 25151EAE3 12/30/2016
10 A-5B 25151EAF0 12/30/2016
11 A-6 25151EAG8 12/30/2016
12 A-7 25151EAH6 12/30/2016
13 A-8 25151EAJ2 01/24/2017
14 M-1 25151EAK9 12/30/2016
15 M-2 25151EAL7 12/30/2016
16 M-3 25151EAM5 12/30/2016
17 M-4 25151EAN3 12/30/2016
18 M-5 25151EAP8 12/30/2016
19 M-6 25151EAQ6 12/30/2016
20 M-7 25151EAR4 12/30/2016
21 M-8 25151EAS2 12/30/2016
22 M-9 25151EAT0 12/30/2016
23 M-10 25151EAU7 12/30/2016
24 M-11 25151EAV5 12/30/2016
25 P 25151EAX1 12/30/2016
26 CE 25151EAW3 12/30/2016
27 R 25151EAY9 12/30/2016
28 Totals NaN NaN
29 This report is compiled by me, N... NaN NaN
30 All Record Dates are based upon the governing ... NaN NaN
31 NaN NaN NaN
所以你看,没有真正的列标题。现在我想要搜索值A-1。
可能是,在DF中值A-1是两次甚至更多次。
我想使用get_loc函数:
df.index.get_loc('A1',method='nearest')]
然后我收到以下错误:
File "pandas/index.pyx", line 132, in pandas.index.IndexEngine.get_loc (pandas/index.c:4433)
File "pandas/index.pyx", line 156, in pandas.index.IndexEngine.get_loc (pandas/index.c:4363)
KeyError: 'A-1'
所以我猜不可能在这个DF上应用get_loc函数。
有没有人有想法解决这个问题,还是我需要进行列式或行式搜索?