I have an array of prediction data, processed from Linear Regression, and now I want to merge/insert the prediction data to the main data frame. My prediction data consists of 7 x 1 array, which is prediction for one of the main data frame's column. Here is the bottom part of main data frame, and here is the array of prediction data.
I've been thinking of some ways to solve this;
using
fillna()
(since it's null values I want to change):#Not real code #df = main data frame #inv_y = array of prediction value df['Cart'].isnull().fillna(value=dict([(inv_y['Cart'].T)]), inplace=True)
iloc
,df['Cart'].iloc[[69,70,71,72,73,74,75]] = inv_y
loc
withisnull
,b = inv_y.loc[~inv_y_['Cart'].isnull()] df.loc[df['Cart'].isnull(),['Cart']]=b
append
(I couldn't put the code here since I already deleted it),etc.
None of these worked out. When running these codes (and the other varieties that I don't put them here, just too much), the errors are always about dimensions or data type (whether the input should be scalar
, dict
, etc). For example, when using fillna()
, the attribute error message is 'tuple' object has no attribute 'T'
so I transposed the array (and still it refused to work).
I'm really open to other suggestions of methods for the solution, it will be much appreciated.