Yonela Nuba
Yonela Nuba

Reputation: 143

DataFrame constructor not properly called when trying to create a dataframe from two datasets

Greetings data scientists.

I am currently trying to create a DataFrame by extracting one column from a dataset and combine it with my predicted data. My predicted data is in a form of ndarray and I can't just concatenate the two I have to create a dataframe, my code for creating this dataframe is:

df = pd.DataFrame(data = (test_set['SK_ID_CURR_x'],pred_prob), columns = ['SK_ID_CURR','TARGET'])

I am currently getting this error, I need help, please.

ValueError: DataFrame constructor not properly called!

Upvotes: 2

Views: 249

Answers (1)

jezrael
jezrael

Reputation: 862431

If length pred_prob is same with test_set, use DataFrame.assign:

df = test_set[['SK_ID_CURR_x']].assign(TARGET = pred_prob)

Upvotes: 2

Related Questions