【发布时间】:2022-01-06 20:22:08
【问题描述】:
所以我有这个 Excel 表,其中有一列并用 1 和 0 填充
4 表示列中 1 的最大数量,我不知道如何获得该数字。 我想知道是否有办法让它在 excel 中返回类似的内容:
这样在数字停止重复后会有一个新列,它会告诉你它重复了多少次。
我用 python 做这个的想法是这样的,但我还没有。
listas = [1,1,0,1,0,1,1,1,1,0]
new_column = []
count = 1
for i in range(len(listas)):
print(listas[i])
if listas[i] == 1:
new_column.append(count)
if listas[i+1] == 1:
count = count + 1
new_column.append(count)
# so if the first integer is 1 check the one in the next position and if 1 coninute checking until 0
所以new_column 是[2,0,1,0,4,0]
返回 0 或 na 所以它只是空的
我将如何在 excel 或 python 中完成此操作?
【问题讨论】: