Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有几张桌子,每张桌子都有自己的结构。表可能从 Cell(C6) 或类似的东西开始。其中一些是水平的,一些是垂直的。我想将表数据提取到pandas数据框中。现在我通过定义第一个列标题并删除之前的所有内容来实现它。有没有合适和通用的方法呢?
pandas
在:
出去:
如果您在 excel 中将文件保存为 .csv 格式,则可以使用它来跳过初始空间:
import pandas as pd pd.read_csv('directory/filename.csv', skipinitialspace=True)
然后,您可以在单元格中使用所需的列和行。