如何找出最长的数字? [英] How do I find out the longest run of a number?
问题描述
对我来说,这似乎是一个琐碎的问题,但我无法正确完成.我的数据集的一部分看起来像这样
This seemed like a trivial question to me, but I cannot get it done correctly. Part of my dataset looks like this
1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0
,其中包含两个由1组成的游程"(不确定单词是否正确),一个长度为3,另一个长度为5.
and contains two "runs" of 1 (not sure if that’s the correct word), one with a length 3, the other with a length of 5.
如何使用Google文档或类似的电子表格应用程序来查找最长的运行时间?
How can I use Google Docs or similar spreadsheet applications to find the longest of those runs?
推荐答案
在Excel中,您可以使用一个公式来获取最大连续1个数字,即
In Excel you can use a single formula to get the maximum number of consecutive 1s, i.e.
=MAX(FREQUENCY(IF(A2:A100=1,ROW(A2:A100)),IF(A2:A100<>1,ROW(A2:A100))))
已通过 CTRL + SHIFT + ENTER
在Google表格中,您可以使用相同的公式,但将其包装在arrayformula中,而不是使用CSE,即
In Google Sheets you can use the same formula but wrap in arrayformula rather than use CSE, i.e.
=arrayformula(MAX(FREQUENCY(IF(A2:A100=1,ROW(A2:A100)),IF(A2:A100<>1,ROW(A2:A100)))))
假设A2:A100中的数据没有空格
Assumes data in A2:A100 without blanks
这篇关于如何找出最长的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!