Aly
Aly

Reputation: 367

How to create Pandas Dataframe from lists?

I have four lists like this:

A = ['column_1',
     'column_2',
     'column_3']

B = ['string_1',
     'string_2',
     'string_3']

numA = [1,2,3]
numB = [4,5,6] 

Is there is way to make Dataframe which as column names will take both lists A and B and as an row both lists numA and numB? So it will look like this:

column_1    column_2    column_3    string_1    string_2    string_3
    1           2           3           4           5           6

Upvotes: 0

Views: 37

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150735

Try:

pd.DataFrame([numA+numB], columns=A+B)

Upvotes: 3

Related Questions