| | Status | Failed | In Progress | Passed | Untested |
|---|-------------------------|--------|-------------|--------|----------|
| 2 | P0 Dry Run - 13/02/18 | 2.0 | | 143.0 | 5.0 |
| 3 | P1 Test Plan - 06/02/18 | 4.0 | | 247.0 | 367.0 |
| 4 | P2 Test plan - 03/01/18 | 22.0 | 2.0 | 496.0 | 54.0 |
msft = pd.read_csv("C:\\Users\\gomathis\\Downloads\\week_071.csv")
msft = msft[['Passed', 'Failed', 'Blocked', 'In Progress', 'Not_Implemented', 'Not Applicable', 'Clarification Opened', 'Untested']]
msft.to_csv("C:\\Users\\gomathis\\Downloads\\week_072.csv")
KeyError: "['Blocked'] not in index"
我需要一个例外的专栏,可能现在不可用,但在未来它可能会来。所以帮我解决这个问题。你知道吗
使用
csv.DictReader.fieldnames
属性,找出CSV中存在哪些列,然后找到这些列的交集。你知道吗首先,指定所需的列。你知道吗
接下来,使用
csv.DictReader
读取CSV的头文件(这不会读取整个文件!)。你知道吗现在,找到集合交集,并将其传递给
pd.read_csv
中的usecols
:最后,要填充缺少的列,请使用set difference并调用
df.assign
:相关问题 更多 >
编程相关推荐