Code Sample, a copy-pastable example if possible

df = pd.DataFrame(data={'a':[0,0]})
# df['b'] = None
# df['b'] = df['b'].astype('object')
df.at[0, 'b'] = ['a']
df.at[1, 'b'] = ['a']

>>> df
   a    b
0  0    a
1  0  [a]

Problem description

df.at[0, 'b'] should be ['a'] instead of 'a'. I understand that it does not work when while adding the column but it feels inconsistent anyways. When adding line 2 and 3 it works as expected.

Expected Output

>>> df
   a    b
0  0  [a]
1  0  [a]

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit : None python : 3.7.6.final.0 python-bits : 64 OS : Windows OS-release : 10 machine : AMD64 processor : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : None.None pandas : 0.25.3 numpy : 1.18.0 pytz : 2019.3 dateutil : 2.8.1 pip : 19.3.1 setuptools : 41.2.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 2.10.3 IPython : 7.10.2 pandas_datareader: None bs4 : None bottleneck : None fastparquet : None gcsfs : None lxml.etree : None matplotlib : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pytables : None s3fs : None scipy : 1.4.1 sqlalchemy : None tables : None xarray : None xlrd : None xlwt : None xlsxwriter : None

Comment From: ellequelle

DataFrame.at isn't intended for creating new columns. From the docs:

DataFrame.at
...
    Raises
    ------
    KeyError
        If 'label' does not exist in DataFrame.

It should work if you uncomment your second line:

df = pd.DataFrame(data={'a':[0,0]})
df['b'] = None
df.at[0, 'b'] = ['a']
df.at[1, 'b'] = ['a']

>>> df
   a    b
0  0  [a]
1  0  [a]

Comment From: TomAugspurger

That line of docs was added in https://github.com/pandas-dev/pandas/pull/20290, and doesn't appear to be tested. It's not clear that that's the intentional behavior.

Comment From: phofl

This seems to work now, may need tests

Comment From: FactorizeD

take

Comment From: topper-123

This isn't actually fixed in v2.0.0rc1 AFAIKS, i.e. I get the same result as OP.

In general, the support in Pandas for non-scalar values is not all that good, so maybe not so surprising this is happening.