python - Require minimum number of data points for resampling? -


is there way make

df2=df2.resample('d',how="mean",label="left",closed="left") 

requires number of points (say 10) make average. , if there isn't nan day

data set looks like:

2004-02-27 20:00:00,2.5666666666666678,0.8638333333333333,,,,,,,,2.5666666666666678,,,,,,4.9,1.0,1.0,1.9088083333333328,0.0214,2.218625,0.0214,246.66666666666663,9.866666666666667,0.0,1.0,1.0 2004-02-27 21:00:00,8.216666666666667,0.95425,,,,,,,,8.216666666666667,,,,,,4.9,1.0,1.0,1.909341666666667,0.0214,2.2172416666666668,0.0214,251.91666666666663,11.308333333333335,0.0,1.0,1.0 2004-02-27 22:00:00,5.116666666666666,0.9855,,,,,,,,5.116666666666666,,,,,,4.9,1.0,1.0,1.9110833333333337,0.0214,2.2185916666666663,0.0214,257.1666666666667,12.54166666666667,0.0,1.0,1.0 

you can create boolean mask tells enough data points exist.

enough_points = df2.resample("d", label="left", closed="left").count() >= 10

then calculate means , filter them mask.

means = df2.resample("d", label="left", closed="left").mean()
good_means = means[enough_points]


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -