#create NumPy array for 'blocks' blocks = np.array([2, 3, 1, 0, 2, 7, 8, 2]) #add 'blocks' array as new column in DataFrame df['blocks'] = blocks.tolist()
Here is what the above code is Doing:
1. Create a NumPy array for the ‘blocks’ column.
2. Add the NumPy array as a new column in the DataFrame.
3. Convert the NumPy array to a list.
The last step is necessary because the DataFrame expects a list, not a NumPy array.