我正在将电子表格的内容读入 pandas。 DataNitro 有一个方法可以将矩形单元格选择作为列表返回。所以
table = Cell("A1").table
给予
table = [['Heading1', 'Heading2'], [1 , 2], [3, 4]]
headers = table.pop(0) # gives the headers as list and leaves data
我正忙着写代码来翻译这个,但我的猜测是它是如此简单的使用,必须有方法来做到这一点。似乎无法在文档中找到它。任何指向可以简化此方法的方法的指针?
最佳答案
直接调用pd.DataFrame
构造函数:
df = pd.DataFrame(table, columns=headers)
df
Heading1 Heading2
0 1 2
1 3 4
https://stackoverflow.com/questions/19112398/