我已经开始探索 Quip API。
我在 Quip 中创建了一个电子表格,其中包含以下详细信息:
- 添加了电子表格的标题
- 在电子表格中添加了以下数据:
ID | 姓名 |
---|---|
1 | 哈利 |
2 | 赫敏 |
3 | 罗恩 |
这是我试图从 Quip 中读取的内容:
import quip
import pandas as pd
import numpy as np
import html5lib
client = quip.QuipClient(token, base_url = baseurl)
rawdictionary = client.get_thread(thread_id)
dfs=pd.read_html(rawdictionary['html'])
raw_df = dfs[0]
raw_df.drop(raw_df.columns[[0]], axis = 1, inplace = True)
#raw_df.dropna(axis=0,inplace=True)
print(raw_df.replace(r'^\s+$', np.nan, regex=True))
我尝试使用 nan 对象删除行,并尝试用 nan 替换空白字符串。但是,我仍然看到这些空行和列出现在数据框中,例如:
A B C D E F G H I J K L M N O P
0 id name
1 1 harry
2 2 hermione
3 3 ron
4
5
6
7
8
9
10
11
12
13
14
15
16
17
。
问题
- 通过 Python 阅读 Quip 电子表格的最佳方法是什么?
- 如何清理多余的行和列,并仅处理具有有效记录和标题的行作为
id
和name
在熊猫数据框中? raw_df.dropna(axis=0,inplace=True)
在我运行时添加后print(raw_df)
,我得到了None
。为什么?