我有一个大型时间序列数据框。我想编写一个函数,将这个大数据帧任意分割成 N 个连续的子周期作为新数据帧,以便可以轻松地对每个较小的数据帧进行分析。
我有这行代码,可以将大数据帧分割成均匀的子周期。我需要一个函数来输出这些分割的数据帧。
np.array_split(df, n) #n = arbitrary amount of new dataframes
Run Code Online (Sandbox Code Playgroud)
我希望每个新的数据帧都被标记为 1,2,3,4 等,用于它代表的每个子周期。因此返回 N 个数据帧,这些数据帧均根据初始大数据帧的时间性质进行标记。
df before the function applied
1 43.91 -0.041619
2 43.39 0.011913
3 45.56 -0.048801
4 45.43 0.002857
5 45.33 0.002204
6 45.68 -0.007692
7 46.37 -0.014992
8 48.04 -0.035381
9 48.38 -0.007053
3 new df's after function split applied
df1
1 43.91 -0.041619
2 43.39 0.011913
3 45.56 -0.048801
df2
4 45.43 0.002857
5 45.33 0.002204
6 45.68 -0.007692
df3
7 46.37 …Run Code Online (Sandbox Code Playgroud) 我有一本11页的工作簿。我需要删除所有显示#N / A的工作表中的行。我将如何去做呢?
我已经写了一些代码,请参见下文,该代码使我只能删除当我的excel文件打开到该特定选项卡时出现的#N / A行。它不会遍历整个工作簿。
Sub RemoveErrorsLoop()
Dim WS_Count As Integer
Dim I As Integer
' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For I = 2 To WS_Count
Cells.SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Delete
Next I
End Sub
Run Code Online (Sandbox Code Playgroud)
我想要可以遍历我所有工作表的代码,并删除具有#N / A的行。谢谢你的帮助!