没有NaN时开始时间序列数据

时间:2019-01-22 00:27:59

标签: python pandas dataframe

我目前有一些时间序列数据,并在17520的窗口上应用了滚动平均值。

因此,在我的数据开头之前,像这样:

SETTLEMENTDATE  ==
0  2006/01/01 00:30:00  8013.27833   ...     5657.67500    20.03
1  2006/01/01 01:00:00  7726.89167   ...     5460.39500    18.66
2  2006/01/01 01:30:00  7372.85833   ...     5766.02500    20.38
3  2006/01/01 02:00:00  7071.83333   ...     5503.25167    18.59
4  2006/01/01 02:30:00  6865.44000   ...     5214.01500    17.53

现在看起来像这样:

        SETTLEMENTDATE  =
0  2006/01/01 00:30:00         NaN   ...            NaN      NaN
1  2006/01/01 01:00:00         NaN   ...            NaN      NaN
2  2006/01/01 01:30:00         NaN   ...            NaN      NaN
3  2006/01/01 02:00:00         NaN   ...            NaN      NaN
4  2006/01/01 02:30:00         NaN   ...            NaN      NaN

在没有NaN的情况下如何获取数据以便仅开始数据? (还要确保日期匹配)

=

1 个答案:

答案 0 :(得分:1)

您可以将private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBoxSelector.ScrollIntoView(ListBoxSelector.SelectedItem); } rolling一起使用

min_periods = 1

也可以尝试使用loo,您无需一一编写列

data['NSW DEMAND'] = data['NSW DEMAND'].rolling(17520,min_periods=17520).mean()

根据您的评论

youcols=['xxx'...'xxx1']
for x in youcols:
    data[x]=data[x].rolling(17520,min_periods=1).mean()

然后,

for x in youcols:
    data[x]=data[x].rolling(17520,min_periods=1).mean()