Python Pandas "All arrays must be of the same length" Problem

Question:

I am getting an error like this. Thank you in advance for your solutions.

ValueError: All arrays must be of the same length

a = {"Ana Linkler":linkler, "İç Linkler":ic_linkler, "Sorular":sorular}
df = pd.DataFrame(a)
Asked By: Abdurrahman AY

||

Answers:

You can try this.

a = {"Ana Linkler":linkler, "İç Linkler":ic_linkler, "Sorular":sorular}
df = pd.DataFrame.from_dict(a, orient='index')
Answered By: Kingshuk Basak

Add df = df.transpose() at the end, to reach the target index and columns position.

a = {"Ana Linkler":linkler, "İç Linkler":ic_linkler, "Sorular":sorular}
df = pd.DataFrame.from_dict(a, orient='index')
df = df.transpose()

Duplicate question: Python Pandas ValueError Arrays Must be All Same Length

Answered By: hrdom
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.