[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]

Notice that an array was inserted, where a scalar was expected. The issue is present in both 0.22 and master.

The same issue is if we use loc instead of iloc. However, if we insert a numeric series instead of a string series, everything is ok:

[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 

EDIT: the issue can be simplified further:

[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

So it seems like a very specific bug, concerning insertion into the last column of a dataframe.

Expected Output

Expected is that a scalar value is inserted into the data frame, and not an array.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: 49714e8eb2d102b183db60b7d07a5321bfb0cf31 python: 3.6.3.final.0 python-bits: 32 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None pandas: 0.22.0.dev0+669.g49714e8 pytest: 3.3.1 pip: 9.0.1 setuptools: 38.2.5 Cython: 0.26.1 numpy: 1.13.3 scipy: 1.0.0 pyarrow: None xarray: None IPython: 6.2.1 sphinx: 1.6.3 patsy: 0.4.1 dateutil: 2.6.1 pytz: 2017.3 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: 2.1.0 openpyxl: 2.4.9 xlrd: 1.1.0 xlwt: 1.3.0 xlsxwriter: None lxml: None bs4: None html5lib: 1.0b10 sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.9.6 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None

Comment From: jreback

xref #14592 xref #19474 xref #16864

I'll mark it though the above are all tied up in this. Assigning a list requires inference wether it should resolve to an error (if mismatching the length), or be broadcast

a PR to investigate / fix would be welcome.

Comment From: jreback

actually on reflection, you are assigning to a single list-like slot and you have a len(1) list

In [14]: df.iloc[0, 1:] = ['a', 'b']
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-14-ddcf638d1f6e> in <module>()
----> 1 df.iloc[0, 1:] = ['a', 'b']

~/pandas/pandas/core/indexing.py in __setitem__(self, key, value)
    185             key = com._apply_if_callable(key, self.obj)
    186         indexer = self._get_setitem_indexer(key)
--> 187         self._setitem_with_indexer(indexer, value)
    188 
    189     def _has_valid_type(self, k, axis):

~/pandas/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value)
    591 
    592                     if len(labels) != len(value):
--> 593                         raise ValueError('Must have equal len keys and value '
    594                                          'when setting with an iterable')
    595 

ValueError: Must have equal len keys and value when setting with an iterable

e.g. the above should be clear that the list must be the same length. This is almost exactly #19474, closing as a duplicate