I have the following data frame:
df = pd.DataFrame({'id': [1, 2, 3, 4],
'a': ['on', 'on', 'off', 'off'],
'b': ['on', 'off', 'on', 'off']})
How can I create a new column df['new'] with the type of NumPy arrays/lists so that I can perform operations like:
df.loc[1, 'new'] = np.array([2 , 'l'])
#or
df.loc[1, 'new'] = [2 , 'l']
objectdtype array column can hold anything - array, list, dict, string, None`dataframe? Just put it there.ValueError: cannot set using a multi-index selection indexer with a different length than the value