【发布时间】:2023-01-14 23:30:16
【问题描述】:
| 1 | 2 | 3 | 4 | Combined | Series |
|---|---|---|---|---|---|
| 0.5 | 5 | 10 | Nan | 0.5, 5, 10 | Increaseing |
| 1 | 2 | 3 | 4 | 1, 2, 3, 4 | Increasing |
| 8 | 5 | 3 | -1 | 8, 5, 3, -1 | Decreasing |
| 4 | 8 | 5 | 3 | 4, 8, 5, 3 | neither |
我有一个包含以上列 [1,2,3,4,Combined] 的表格
我如何尝试自动化 python 中组合列的系列确定?
def test(combine): return "Increasing." if all(combine[i] < combine[i + 1] for i in range(len(combine) - 1)) else "Decreasing." if all(combine[i + 1] < combine[i] for i in range(len(combine) - 1)) else "neither!"但这给我带来了结果“0”的错误
【问题讨论】:
-
错误信息是什么?列表中的
Combined是什么。 -
@WingedSeal,这是一个关键错误“KeyError:0' Combined 只是我创建的结合列 1,2,3,4 的列
-
我无法重现错误,它工作得很好。除非您将除 int 列表之外的其他内容传递给测试函数。