<h4 dir="auto">MnWE</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd

the_int_column = pd.Series([1, 2, 3])
foobar = pd.DataFrame(columns=(&quot;ints&quot;,))
foobar.loc[&quot;First&quot;] = [the_int_column.sum()]

print(foobar.dtypes)

the_float_column = pd.Series([1.0, 2.0, 3.0])
floatbar = pd.DataFrame(columns=(&quot;floats&quot;,))
floatbar.loc[&quot;First&quot;] = [the_float_column.sum()]

print(floatbar.dtypes)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-s1">the_int_column</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>])
<span class="pl-s1">foobar</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">columns</span><span class="pl-c1">=</span>(<span class="pl-s">"ints"</span>,))
<span class="pl-s1">foobar</span>.<span class="pl-s1">loc</span>[<span class="pl-s">"First"</span>] <span class="pl-c1">=</span> [<span class="pl-s1">the_int_column</span>.<span class="pl-en">sum</span>()]

<span class="pl-en">print</span>(<span class="pl-s1">foobar</span>.<span class="pl-s1">dtypes</span>)

<span class="pl-s1">the_float_column</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>([<span class="pl-c1">1.0</span>, <span class="pl-c1">2.0</span>, <span class="pl-c1">3.0</span>])
<span class="pl-s1">floatbar</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">columns</span><span class="pl-c1">=</span>(<span class="pl-s">"floats"</span>,))
<span class="pl-s1">floatbar</span>.<span class="pl-s1">loc</span>[<span class="pl-s">"First"</span>] <span class="pl-c1">=</span> [<span class="pl-s1">the_float_column</span>.<span class="pl-en">sum</span>()]

<span class="pl-en">print</span>(<span class="pl-s1">floatbar</span>.<span class="pl-s1">dtypes</span>)</pre></div>
<p dir="auto">This yields</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="ints    object
dtype: object
floats    float64
dtype: object"><pre class="notranslate"><span class="pl-s1">ints</span>    <span class="pl-s1">object</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span>
<span class="pl-s1">floats</span>    <span class="pl-s1">float64</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">Assigning the sum of a Series of (vanilla Python) <code class="notranslate">int</code>s to a DataFrame leads to not specific enough type inference on the frame: it keeps the object type. Vanilla <code class="notranslate">float</code>s work fine, as the second example demonstrates.</p>
<p dir="auto">This is an issue for some testing I'm doing, where I want to ensure a column of these sums contains only numeric data, and specifically integers.</p>
<p dir="auto">Might be related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="312295205" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/20635" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/20635/hovercard" href="https://github.com/pandas-dev/pandas/issues/20635">#20635</a>.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">Expected output:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="ints       int64
dtype: object
floats    float64
dtype: object"><pre class="notranslate"><span class="pl-s1">ints</span>       <span class="pl-s1">int64</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span>
<span class="pl-s1">floats</span>    <span class="pl-s1">float64</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span></pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.22.0
pytest: 3.3.2
pip: 9.0.1
setuptools: 38.4.0
Cython: 0.27.3
numpy: 1.14.0
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: 1.6.6
patsy: 0.5.0
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.2
openpyxl: 2.4.10
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.1
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
</details>
<p dir="auto">When I run this code on 0.17.0 on Python 3.5.0</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import pandas as pd
d = pd.DataFrame(data=[[2, 1]])
print(d.index)
print((d.
 groupby(level=0).
 apply(lambda d: 
       d.sort_values(0)
      )
 ).index)"><pre class="notranslate"><code class="notranslate">import pandas as pd
d = pd.DataFrame(data=[[2, 1]])
print(d.index)
print((d.
 groupby(level=0).
 apply(lambda d: 
       d.sort_values(0)
      )
 ).index)
</code></pre></div>
<p dir="auto">I get</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Int64Index([0], dtype='int64')
MultiIndex(levels=[[0], [0]],
           labels=[[0], [0]])"><pre class="notranslate"><code class="notranslate">Int64Index([0], dtype='int64')
MultiIndex(levels=[[0], [0]],
           labels=[[0], [0]])
</code></pre></div>
<p dir="auto">The index gets duplicated (and turned into a multiindex) as a result of the <code class="notranslate">sort</code> within the <code class="notranslate">groupby</code>.</p>
<p dir="auto">Appears to be a bug to me.</p>