'column' not in index, but hell it is. Seems like a bug...
I have a dataframe called delivery and when I print(delivery.columns) I get the following:

    Index(['Complemento_endereço', 'cnpj', 'Data_fundação', 'Número',
       'Razão_social', 'CEP', 'situacao_cadastral', 'situacao_especial', 'Rua',
       'Nome_Fantasia', 'last_revenue_normalized', 'last_revenue_year',
       'Telefone', 'email', 'Capital_Social', 'Cidade', 'Estado',
       'Razão_social', 'name_bairro', 'Natureza_Jurídica', 'CNAE', '#CNAE',
       'CNAEs_secundários', 'Pessoas', 'percent'],
      dtype='object')

Well, we can clearly see that there is a column 'Rua'.

Also, if I print(delivery.Rua) I get a proper result:

    82671                         R JUDITE MELO DOS SANTOS
    817797                                R DOS GUAJAJARAS
    180081           AV MARCOS PENTEADO DE ULHOA RODRIGUES
    149373                                 AL MARIA TEREZA
    455511                               AV RANGEL PESTANA
    ...

Even if I write "if 'Rua' in delivery.columns: print('here I am')" it does print the 'here I am'. So 'Rua' is in fact there.

Well, in the immediate line after I have this code:

    delivery=delivery.set_index('cnpj')[['Razão_social','Nome_Fantasia','Data_fundação','CEP','Estado','Cidade','Bairro','Rua','Número','Complemento_endereço','Telefone','email','Capital_Social', 'CNAE', '#CNAE', 'Natureza_Jurídica','Pessoas' ]]

And voilá, I get this weird error:

    Traceback (most recent call last):
    File "/file.py", line 45, in <module>
       'Telefone', 'email', 'Capital_Social', 'Cidade', 'Estado',
       'Razão_social', 'name_bairro', 'Natureza_Jurídica', 'CNAE', '#CNAE',
    'Telefone','email','Capital_Social', 'CNAE', '#CNAE', 'Natureza_Jurídica','Pessoas' ]]
       'CNAEs_secundários', 'Pessoas', 'percent'],
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/frame.py", line 1991, in __getitem__
      dtype='object')
    return self._getitem_array(key)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/frame.py", line 2035, in _getitem_array
    indexer = self.ix._convert_to_indexer(key, axis=1)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/indexing.py", line 1214, in _convert_to_indexer
    raise KeyError('%s not in index' % objarr[mask])
    KeyError: "['Rua'] not in index"


Can someone help? I tried stackoverflow but no one could help. I'm starting to think I'm crazy and 'Rua' is an illusion of my troubled mind.

**ADDITIONAL INFO**

I'm using this code right before the error line:

    delivery=pd.DataFrame()

    for i in selection.index:
        sample=groups.get_group(selection['#CNAE'].loc[i]).sample(selection['samples'].loc[i])
        delivery=pd.concat((delivery,sample)).sort_values('Capital_Social',ascending=False)

 
    print(delivery.columns)
    print(delivery.Rua)
    print(delivery.set_index('cnpj').columns)

    delivery=delivery.set_index('cnpj')[['Razão_social','Nome_Fantasia','Data_fundação','CEP','Estado','Cidade','Bairro','Rua','Número','Complemento_endereço',
                                     'Telefone','email','Capital_Social', 'CNAE', '#CNAE', 'Natureza_Jurídica','Pessoas' ]]

**EDIT**

New weird stuff:
I gave up and deleted 'Rua' from that last piece of code, wishing that it would work. For my surprise, I had the same problem but now with the column 'Número'.

    delivery=delivery.set_index('cnpj')[['Razão_social','Nome_Fantasia','Data_fundação','CEP','Estado','Cidade','Bairro','Número','Complemento_endereço',
                                                     'Telefone','email','Capital_Social', 'CNAE', '#CNAE', 'Natureza_Jurídica' ]]

    KeyError: "['Número'] not in index"

**EDIT 2**

And then I gave up on 'Número' and took it out. Then the same problem happened with 'Complemento_endereço'. Then I deleted 'Complemento_endereço'. And it happend to 'Telefone' and so on.

** EDIT 3 **

If I do a pd.show_versions(), that's the output:

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.0.final.0
python-bits: 64
OS: Darwin
OS-release: 16.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.1
nose: None
pip: 8.1.2
setuptools: 18.2
Cython: None
numpy: 1.11.0
scipy: 0.17.1
statsmodels: 0.6.1
xarray: None
IPython: None
sphinx: None
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.5.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.1.3
pymysql: 0.7.11.None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None
None