A small, complete example of the issue


In [2]: df = pd.DataFrame({'float' : range(4),
   ...:                    'int'   : range(4)},
   ...:                   index=pd.MultiIndex.from_product([[1,2]]*2))

In [3]: df['float'] = df['float'].astype(float)

In [4]: df.loc[(1,), 'int']
Out[4]: 
1    0
2    1
Name: int, dtype: int64

Right!

In [5]: df.loc[(1,), 'int'].loc[1]
Out[5]: 0

Right!


In [6]: df.loc[(1,1), 'int']
Out[6]: 0.0

Wrong!

Expected Output

Still an integer.

Output of pd.show_versions()

In [7]: pd.show_versions() ## INSTALLED VERSIONS commit: None python: 3.5.1.final.0 python-bits: 64 OS: Linux OS-release: 4.5.0-2-amd64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: it_IT.utf8 LOCALE: it_IT.UTF-8 pandas: 0.19.0+1.g96b364a nose: 1.3.7 pip: 1.5.6 setuptools: 18.4 Cython: 0.23.4 numpy: 1.10.4 scipy: 0.16.0 statsmodels: 0.8.0.dev0+f80669e xarray: None IPython: 5.1.0.dev sphinx: 1.4.5 patsy: 0.3.0-dev dateutil: 2.2 pytz: 2012c blosc: None bottleneck: 1.1.0 tables: 3.2.2 numexpr: 2.5 matplotlib: 1.5.1 openpyxl: None xlrd: 0.9.4 xlwt: 1.1.2 xlsxwriter: 0.7.3 lxml: None bs4: 4.4.0 html5lib: 0.999 httplib2: 0.9.1 apiclient: 1.5.0 sqlalchemy: 1.0.11 pymysql: None psycopg2: None jinja2: 2.8 boto: 2.38.0 pandas_datareader: 0.2.1

Comment From: toobaz

Oh, my example above is actually unnecessarily complicated - the index can be a normal Int64Index, as in


In [8]: df = pd.DataFrame({'float' : range(4),
   ...:                    'int'   : range(4)})

In [9]: df['float'] = df['float'].astype(float)

In [10]: df.loc[2, 'int']
Out[10]: 2.0

Comment From: jreback

duplicate of https://github.com/pydata/pandas/issues/11617