I have a Pandas DataFrame that I\'m creating row-by-row (I know, I know, it\'s not Pandorable/Pythonic..). I\'m creating elements using .loc like so
You need to make sure two things:
A hacky way to do this is to use a Series with []:
In [11]: df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
In [12]: df.loc[[0], 'A'] = pd.Series([[]])
In [13]: df
Out[13]:
A B
0 [] 2
1 3 4
pandas doesn't really want you use [] as elements because it's usually not so efficient and makes aggregations more complicated (and un-cythonisable).
In general you don't want to build up DataFrames cell-by-cell, there is (almost?) always a better way.