KeyError when key is present
I got a KeyError when running my program with pandas 0.15.2 on python 3.4.
I have a TimeSeries created from a dp.read_sql_query using a sqlalchemy engine for a sqlite database.
I use this TimeSeries as a storage for data to work on. In each iteration I work on some data and errase it from the series with drop inplace.
It has been working without hassle for some time now, but somehow today it threw a KeyError. By postmortem debugging I verified that the key was indeed present, so I do not know how I could avoid this crash from happening again.

Here is the traceback:

  File "<ipython-input-35-6945f8f1d7ab>", line 1, in <module>
    runfile('C:/Users/u5en/Programação/Projeto Extração/Extração.py', wdir='C:/Users/u5en/Programação/Projeto Extração')

  File "C:\Users\u5en\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 580, in runfile
    execfile(filename, namespace)

  File "C:\Users\u5en\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 48, in execfile
    exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)

  File "C:/Users/u5en/Programação/Projeto Extração/Extração.py", line 448, in <module>
    main()

  File "C:/Users/u5en/Programação/Projeto Extração/Extração.py", line 438, in main
    executor(sap, tarefa, banco )

  File "C:/Users/u5en/Programação/Projeto Extração/Extração.py", line 357, in executor
    extrai_frac(sap, tabela, preencher_sap, linha_a_iterar, leiaute, produto)

  File "C:/Users/u5en/Programação/Projeto Extração/Extração.py", line 284, in extrai_frac
    registra_log(produto, tabela, leiaute, seq, dados[ind_entrada[0]],

  File "C:\Users\u5en\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\frame.py", line 1780, in **getitem**
    return self._getitem_column(key)

  File "C:\Users\u5en\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\frame.py", line 1787, in _getitem_column
    return self._get_item_cache(key)

  File "C:\Users\u5en\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\generic.py", line 1068, in _get_item_cache
    values = self._data.get(item)

  File "C:\Users\u5en\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\internals.py", line 2849, in get
    loc = self.items.get_loc(item)

  File "C:\Users\u5en\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\index.py", line 1402, in get_loc
    return self._engine.get_loc(_values_from_object(key))

  File "pandas\index.pyx", line 134, in pandas.index.IndexEngine.get_loc (pandas\index.c:3807)

  File "pandas\index.pyx", line 154, in pandas.index.IndexEngine.get_loc (pandas\index.c:3687)

  File "pandas\hashtable.pyx", line 696, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12310)

  File "pandas\hashtable.pyx", line 704, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12261)

KeyError: 6

In [36]: debug

> c:\users\u5en\appdata\local\continuum\anaconda3\lib\site-packages\pandas\core\frame.py(1780)**getitem**()
>    1779         else:
> -> 1780             return self._getitem_column(key)
>    1781 

ipdb> key
6

ipdb> u

> c:\users\u5en\programação\projeto extração\extração.py(284)extrai_frac()
>     283                 if tam_bloco==1: #Desiste da entrada única
> --> 284                     registra_log(produto, tabela, leiaute, seq, dados[ind_entrada[0]],
>     285                                  tam_bloco, inicio_dados, fim_dados, "x")

ipdb> ind_entrada[0]
6

ipdb> dados
                                  GUID
6     4E1DCC24F58173FAE10000000A19FF81
7     B07D0F53BB47EF79E10000000A1D00F6
8     5081D6378BE20D30E10000000A1D001D
9     4D4A2852F17736BEE10000000A19FF83
10    A6BF5F5365BB183EE10000000A1D2028
11    9175355128FCEC72E10000000A1D2028
12    DDA3DE53533C041DE10000000A1D2028
13    142207533F63D632E10000000A1D2028
14    50741D7B4FE61F18E10000000A1D0022
15    08485E5381EB4B3EE10000000A1D00F8
16    F4657B5249D9ED18E10000000A1D00F8
17    D0A95451844A9D19E10000000A1D00F8
18    4FD60BFC2B7A1159E10000000A1D0026
19    50920B577EF70BE2E10000000A1D0026
20    765E59539656A375E10000000A1D00F6
21    16FA7B538A6A3A7DE10000000A1D2028
22    E5330753B6589922E10000000A1D2028
23    1748E852010AA076E10000000A1D2028
24    4DD1A2D327FB51F3E10000000A19FF83
25    5085A682BF56192BE10000000A1D0022
26    4E1D0227DB213A10E10000000A19FF82
27    1805E953691ECA44E10000000A1D00F8
28    101E6E52598EE224E10000000A1D00F8
29    DE221954306A8713E10000000A1D00F8
30    4E6EAC19A5F6699EE10000000A19FF81
31    51317752E9E2956EE10000000A1D00F6
32    EEB3D551DEA7923EE10000000A1D00F8
33    20D366516BFE074FE10000000A1D00F8
34    CFFB63534A6A3F12E10000000A1D2028
35    99AC1A50E6C0A128E20030C60D1E02BC
...                                ...
1212  48A25A511DA62E47E10000000A1D00F8
1213  97B754526E0B863CE10000000A1D00F6
1214  E20EFD543AF42D4BE10000000A1D211B
1215  CA250554AEF2857FE10000000A1D00F6
1216  6249EC54DF70A2CBE10000000A1D211B
1217  BD5A73541E886A70E10000000A1D00F6
1218  CB3173544288AC4EE10000000A1D00F8
1219  C96FAC5406FADA26E10000000A1D00F8
1220  7F749754BB617815E10000000A1D211B
1221  E70FEB54E2CBCC70E10000000A1D00F8
1222  EA460854938F9350E10000000A1D2028
1223  EA6E4F54EF75025AE10000000A1D00F8
1224  E3BB98543622BF62E10000000A1D2028
1225  E3DA035508382825E10000000A1D00F6
1226  96BE97545F8ADB4EE10000000A1D00F6
1227  15407352C1CD7A33E10000000A1D2028
1228  EE55BF51D50E2E23E10000000A1D00F6
1229  ECBFAD53CB8DC10DE10000000A1D00F6
1230  F120BC5464E73829E10000000A1D2028
1231  EF2E0E556FDDB927E10000000A1D211B
1232  C4AEAA50BF24A371E2000D3560A76C25
1233  34A84A54A762386DE10000000A1D00F6
1234  F2DF19544FC51832E10000000A1D00F6
1235  DAE89750A2E7A12CE2009DD40A5B4CB2
1236  722CAD53CE9B961FE10000000A1D00F6
1237  EA0EBC5069E94D74E2005420EF347364
1238  F922745456997A40E10000000A1D00F8
1239  E4124A510D49371DE10000000A1D00F8
1240  BFB753526DF6F81BE10000000A1D2028
1241  A0CFDA53E983EA44E10000000A1D2028

[1236 rows x 1 columns]

ipdb> dados[ind_entrada[0]]
**\* KeyError: 6

ipdb> dados[6]
**\* KeyError: 6

ipdb> dados[ind_entrada]
**\* IndexError: indices are out-of-bounds

ipdb> entrada.index
Int64Index([6], dtype='int64')

ipdb> dados[entrada.index.values]
**\* IndexError: indices are out-of-bounds

ipdb> dados[dados.index.values[0]]
**\* KeyError: 6

ipdb> 
