繁体   English   中英

过滤掉周末后使用 Pandas 重新采样

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM