I have the issue that I would like to set all values for a given column using a numpy vector. Consider the following
import pandas as pd
from numpy import arange
from scipy import random
index = pd.MultiIndex.from_product([arange(0,3), arange(10,15)], names=['A', 'B'])
df = pd.DataFrame(columns=['test'], index=index)
someValues = random.randint(0, 10, size=5)
df.loc[0,:]['test'] = someValues
print someValues
print df.loc[0,:]
The output is
Out[423]: array([9, 2, 7, 2, 4])
Out[422]:
test
B
10 NaN
11 NaN
12 NaN
13 NaN
14 NaN
This comes - I guess - from me not providing the indices to the values. How can I do this operation, given that "the order" in which the values appear in the numpy array is going to be the order in which they should be set onto the column?