Pandas ValueError Arrays Must be All Same Length

you can do this to avoid that error

a = {'Links' : lines ,'Titles' : titles , 'Singers': finalsingers , 'Albums':finalalbums , 'Years' : years}
df = pd.DataFrame.from_dict(a, orient="index")
df = df.transpose()

Explanation:

This creates the DataFrame as each key (e.g. 'Links') was a row and like this the missing values are actually missing columns which is no problem for pandas (only missing rows lead to ValueError during creation) After that you transpose the DataFrame (flip the axis) and make the rows to columns, which results the DataFrame you initially wanted.

Leave a Comment