<p dir="auto">we have quite a lot of code to support .mode (internally we use pretty much the same algos as <code class="notranslate">.value_counts()</code>)</p>
<p dir="auto">but unless I am not understanding isn't.</p>
<p dir="auto"><code class="notranslate">x.mode() == x.value_counts(sort=True).index[0]</code> ?</p>
<p dir="auto">if ties, then return a slice of the result</p>
<p dir="auto">e.g.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [17]: Series([1, 1, 1, 2, 2, 2, 3]).value_counts()
Out[17]: 
2    3
1    3
3    1
dtype: int64

In [18]: Series([1, 1, 1, 2, 2, 2, 3]).mode()
Out[18]: 
0    1
1    2
dtype: int64"><pre class="notranslate"><code class="notranslate">In [17]: Series([1, 1, 1, 2, 2, 2, 3]).value_counts()
Out[17]: 
2    3
1    3
3    1
dtype: int64

In [18]: Series([1, 1, 1, 2, 2, 2, 3]).mode()
Out[18]: 
0    1
1    2
dtype: int64
</code></pre></div>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/TomAugspurger/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/TomAugspurger">@TomAugspurger</a></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="[1] df = pd.DataFrame([[1,2]])
[2] df.iloc[0, 1:] = df.iloc[0, 1:].apply('{:+.2f}'.format)
[3] df
   0       1
0  1  [+2.00]"><pre class="notranslate">[<span class="pl-c1">1</span>] <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>([[<span class="pl-c1">1</span>,<span class="pl-c1">2</span>]])
[<span class="pl-c1">2</span>] <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>, <span class="pl-c1">1</span>:] <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>, <span class="pl-c1">1</span>:].<span class="pl-en">apply</span>(<span class="pl-s">'{:+.2f}'</span>.<span class="pl-s1">format</span>)
[<span class="pl-c1">3</span>] <span class="pl-s1">df</span>
   <span class="pl-c1">0</span>       <span class="pl-c1">1</span>
<span class="pl-c1">0</span>  <span class="pl-c1">1</span>  [<span class="pl-c1">+</span><span class="pl-c1">2.00</span>]</pre></div>
<p dir="auto">Notice that an  array was inserted, where a scalar was expected. The issue is present in both 0.22 and master.</p>
<p dir="auto">The same issue is if we use <code class="notranslate">loc</code>  instead of <code class="notranslate">iloc</code>. However, if we insert a numeric series instead of a string series, everything is ok:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="[1] df = pd.DataFrame([[1,2]])
[2] df.iloc[0, 1:] = df.iloc[0, 1:].apply(lambda x: x*2)
[3] df
   0       2
0  1      4 "><pre class="notranslate">[<span class="pl-c1">1</span>] <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>([[<span class="pl-c1">1</span>,<span class="pl-c1">2</span>]])
[<span class="pl-c1">2</span>] <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>, <span class="pl-c1">1</span>:] <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>, <span class="pl-c1">1</span>:].<span class="pl-en">apply</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">x</span><span class="pl-c1">*</span><span class="pl-c1">2</span>)
[<span class="pl-c1">3</span>] <span class="pl-s1">df</span>
   <span class="pl-c1">0</span>       <span class="pl-c1">2</span>
<span class="pl-c1">0</span>  <span class="pl-c1">1</span>      <span class="pl-c1">4</span> </pre></div>
<p dir="auto">EDIT: the issue can be simplified further:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="[1] df = pd.DataFrame([[1, 2]])
[2] df.iloc[0, 1:] = ['a']
[3] df
   0       2
0  1      [a]
[4] df = pd.DataFrame([[1, 2]])
[5] df.iloc[0, 0:] = ['a', 'b']  # ok
   0  1
0  a  b
[6] df = pd.DataFrame([[1, 2, 3]])
[7] df.iloc[0, 1:] = ['a', 'b']  # ok
   0  1  2
0  1  a  b"><pre class="notranslate">[<span class="pl-c1">1</span>] <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>([[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>]])
[<span class="pl-c1">2</span>] <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>, <span class="pl-c1">1</span>:] <span class="pl-c1">=</span> [<span class="pl-s">'a'</span>]
[<span class="pl-c1">3</span>] <span class="pl-s1">df</span>
   <span class="pl-c1">0</span>       <span class="pl-c1">2</span>
<span class="pl-c1">0</span>  <span class="pl-c1">1</span>      [<span class="pl-s1">a</span>]
[<span class="pl-c1">4</span>] <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>([[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>]])
[<span class="pl-c1">5</span>] <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>, <span class="pl-c1">0</span>:] <span class="pl-c1">=</span> [<span class="pl-s">'a'</span>, <span class="pl-s">'b'</span>]  <span class="pl-c"># ok</span>
   <span class="pl-c1">0</span>  <span class="pl-c1">1</span>
<span class="pl-c1">0</span>  <span class="pl-s1">a</span>  <span class="pl-s1">b</span>
[<span class="pl-c1">6</span>] <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>([[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>]])
[<span class="pl-c1">7</span>] <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>, <span class="pl-c1">1</span>:] <span class="pl-c1">=</span> [<span class="pl-s">'a'</span>, <span class="pl-s">'b'</span>]  <span class="pl-c"># ok</span>
   <span class="pl-c1">0</span>  <span class="pl-c1">1</span>  <span class="pl-c1">2</span>
<span class="pl-c1">0</span>  <span class="pl-c1">1</span>  <span class="pl-s1">a</span>  <span class="pl-s1">b</span></pre></div>
<p dir="auto">So it seems like a very specific bug, concerning insertion into the last column of a dataframe.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">Expected is that a scalar value is inserted into the data frame, and not an array.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pandas-dev/pandas/commit/49714e8eb2d102b183db60b7d07a5321bfb0cf31/hovercard" href="https://github.com/pandas-dev/pandas/commit/49714e8eb2d102b183db60b7d07a5321bfb0cf31"><tt>49714e8</tt></a><br>
python: 3.6.3.final.0<br>
python-bits: 32<br>
OS: Windows<br>
OS-release: 10<br>
machine: AMD64<br>
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: None<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.22.0.dev0+669.g49714e8<br>
pytest: 3.3.1<br>
pip: 9.0.1<br>
setuptools: 38.2.5<br>
Cython: 0.26.1<br>
numpy: 1.13.3<br>
scipy: 1.0.0<br>
pyarrow: None<br>
xarray: None<br>
IPython: 6.2.1<br>
sphinx: 1.6.3<br>
patsy: 0.4.1<br>
dateutil: 2.6.1<br>
pytz: 2017.3<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: 2.1.0<br>
openpyxl: 2.4.9<br>
xlrd: 1.1.0<br>
xlwt: 1.3.0<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 1.0b10<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>