尝试使用字典:
d = {}
c = 0
while True:
c += 1
window_data = slider.slide()
d['df%s'%c] = window_data
if slider.reached_end_of_list(): break
毕竟,只需使用d['df1']
和d['df2']
等来进行访问,如果要像df1
和df2
这样直接访问它们,请添加在代码末尾的下面一行:
locals().update(d)
然后df1
和df2
将起作用。
,
您可以使用列表将其存储在列表列表中:
from window_slider import Slider
import numpy
import pandas as pd
list = numpy.array([0,1,2,3,4,5,6,7,8])
bucket_size = 3
overlap_count = 0
slider = Slider(bucket_size,overlap_count)
slider.fit(list)
#Master list which consists of all the lists of arrays
output_list = []
while True:
window_data = slider.slide()
#Convert the window_data array to a list
output_df_list = window_data.tolist()
#Append the "output_df_list" to the master list "output_list"
output_list.append(output_df_list)
print(window_data)
if slider.reached_end_of_list(): break
输出:
print(output_list)
[[0,2],[3,5],[6,8]]
本文链接:https://www.f2er.com/3160313.html