Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I am reading contents of a spreadsheet into pandas. DataNitro has a method that returns a rectangular selection of cells as a list of lists. So

table = Cell("A1").table

gives

table = [['Heading1', 'Heading2'], [1 , 2], [3, 4]]

headers = table.pop(0) # gives the headers as list and leaves data

I am busy writing code to translate this, but my guess is that it is such a simple use that there must be method to do this. Cant seem to find it in documentation. Any pointers to the method that would simplify this?

1 Answer

0 votes
by (41.4k points)

Directly call the pd.DataFrame constructor:

df = pd.DataFrame(table, columns=headers)

df

   Heading1  Heading2

0         1 2

1         3 4

Related questions

Browse Categories

...