0

I have the following data:

data = [
    (132603, 'TV Series', 'hbo', 'Chris Rock', datetime.date(2008, 9, 2), datetime.datetime(2019, 2, 6, 2, 16)), 
    (132605, 'TV Series', 'madman', 'Joanna Lumley', datetime.date(2012, 10, 24), datetime.datetime(2019, 2, 5, 16, 45))
]

And I create a dataframe as follows:

>>> pd.DataFrame(data)

        0          1       2              3           4                   5
0  132603  TV Series     hbo     Chris Rock  2008-09-02 2019-02-06 02:16:00
1  132605  TV Series  madman  Joanna Lumley  2012-10-24 2019-02-05 16:45:00

How would I specify a headers column when creating the dataframe, such as:

pd.DataFrame(data, headers=['id', 'type','network','start','end'])
2
  • pd.DataFrame(data, columns=['id', 'type','network','missing_column','start','end']) your list of headers has 5 entries whereas your data has 6 headers. fix that and use this syntax Commented Feb 9, 2019 at 3:10
  • Try to at least glance at the documentation before posting a question. Commented Feb 9, 2019 at 3:12

1 Answer 1

1

If you check the fine manual page, you'll find that columns= does what you want.

Sign up to request clarification or add additional context in comments.

Comments