Python Panda TIme series re sampling

前端 未结 1 621
渐次进展
渐次进展 2021-01-27 17:42

I am writing scripts in panda but i could not able to extract correct output that i want. here it is problem:

i can read this data from CSV file. Here you can find tabl

相关标签:
1条回答
  • 2021-01-27 18:38

    For resample, you can define two aggregation functions like this:

    def countU(x):
        return sum(i[0] == 'u' for i in x)
    
    def countNotU(x):
        return sum(i[0] != 'u' for i in x)
    
    print df.resample('M', how=[countU, countNotU])
    

    Alternatively, consider groupby.

    0 讨论(0)
提交回复
热议问题