[英]Using Pandas resample after filtering out weekends
我正在结合一些重新采样操作以获得排除周末后的平均每日流量。 在当年的最后一次重采样中,零点再次成为计算的一部分。 我该如何摆脱它们?
df5[df5.index.dayofweek < 5].qKfz_gesamt.resample('1h').mean().resample('1d') \
.sum().resample('1y').mean()
一种方法是在每天重采样后的sum
中使用参数min_count
。 然后周末是 nan 并且不影响使用mean
的年度重采样:
(df5[df5.index.dayofweek < 5].qKfz_gesamt
.resample('1h').mean()
.resample('1d').sum(min_count=1) #here is the parameter
.resample('1y').mean())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.