I have two lists. I have a list of table titles(title_df). my other list is from my contents (prediction_df) to be sorted by titles. I want to populate my contents by titles and create a table in the result.
title_df=[‘a’,’b’]
prediction_df=[‘1′,’2′,’3′,’800800′,’802100′,’800905’]
my table has three rows and two columns
i need your help
>Solution :
Use numpy.reshape, 2 is for 2 columns and -1 is for count number of rows by data, last pass to DataFrame constructor:
df = pd.DataFrame(np.reshape(prediction_df, (-1,2), order='F'), columns=title_df)
print (df)
a b
0 1 800800
1 2 802100
2 3 800905