2

How I can change two numpy array and dataframe and merge them ?

I have:

X

array([1461, 1462, 1463, ..., 2917, 2918, 2919])

and

y_test_pred

array([272229.457876  , 256423.56032314, 281508.5907379 , ...,
       223281.89247352, 223185.78377167, 229313.97269616])

My goal is to make following format:

Id,SalePrice

1461,169000.1

1462,187724.1233

1463,175221

etc.

Many thanks,

Dataleon

1 Answer 1

2

Just construct a dataframe with concat:

df = pd.concat([pd.Series(X), pd.Series(y_test_pred)], axis=1).rename({0:  'Id', 1: 'SalePrice'}, axis=1)
Sign up to request clarification or add additional context in comments.

1 Comment

I got this error:ValueError: arrays must all be same length

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.