簡體   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