하여 배열 루핑 I는 NumPy와 배열을 갖는다.겹치는 윈도우
n=7
overlap = 3
windowed_seq = windowing(seq,n,overlap)
In [24]: windowed_seq
Out[24]: [ 1, 5, ..., 17, 21,
2, 6, ..., 18, 22,
3, 7, ..., 19, 23,
4, 8, ..., 20, 24,
5, 9, ..., 21, 25,
6, 10, ..., 22, 26,
7, 11, ..., 23, 27]
마지막 열 :
25,
26,
27,
28,
29,
30,
31,
?]
하나 개의 요소가 창을 완료 없기 때문에 생략 ..
나는 인터넷에이 솔루션을 찾았지만 배열 작동하지 않습니다 ...
https://www.safaribooksonline.com/library/view/python-cookbook-2nd/0596007973/ch19s08.html
import itertools
def windows(iterable, length=2, overlap=0):
it = iter(iterable)
results = list(itertools.islice(it, length))
while len(results) == length:
yield results
results = results[length-overlap:]
results.extend(itertools.islice(it, length-overlap))
if results:
yield results
if _ _name_ _ == '_ _main_ _':
seq = 'foobarbazer'
for length in (3, 4):
for overlap in (0, 1):
print '%d %d: %s' % (length, overlap,
map(''.join, windows(seq, length, overlap)))
내 어레이에서 작동하도록 도와 주시겠습니까? 당신이 사용할 수있는
예상 결과와 함께 입력을 표시 할 수 있습니까? – NoobEditor
@NoobEditor 나는 최대 예상 출력 – gabboshow