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 can use pd.at instead:
df = pd.DataFrame()
df['B'] = [1, 2, 3]
df['A'] = None
df.at[1, 'A'] = np.array([1, 2, 3])
When you use pd.loc, pandas thinks you are interacting with a set of rows. So if you try to assign an array using pd.loc, pandas will try to match each element of an array with a corresponding element accessed by pd.loc, hence the error.