擅长:python、mysql、java
<p>您可以在序列上应用<code>diff()</code>,然后只计算差值为1且实际值高于截止值的连续条目数。最大计数是连续值的最大数目。在</p>
<p>第一次计算<code>diff()</code>:</p>
<pre><code>df = pd.DataFrame({"a":[1, 2, 6, 7, 8, 3, 2, 3, 6, 10, 2, 1, 0, 2]})
df['b'] = df.a.diff()
df
a b
0 1 NaN
1 2 1.0
2 6 4.0
3 7 1.0
4 8 1.0
5 3 -5.0
6 2 -1.0
7 3 1.0
8 6 3.0
9 10 4.0
10 2 -8.0
11 1 -1.0
12 0 -1.0
13 2 2.0
</code></pre>
<p>现在计算连续序列:</p>
^{pr2}$