Search code examples
pythonpandassample-data

How to compare frequencies/sampling rates in pandas?


is there a way to say that '13Min' is > '59S' and <'2H' using the frequency notation in pandas?


Solution

  • In [4]: from pandas.tseries.frequencies import to_offset
    
    In [5]: to_offset('59s') < to_offset('1T')
    Out[5]: True
    
    In [6]: to_offset('13T') > to_offset('59s')
    Out[6]: True
    
    In [7]: to_offset('13T') < to_offset('59s')
    Out[7]: False
    
    In [8]: to_offset('13T') > to_offset('2H')
    Out[8]: False
    
    In [10]: to_offset('13T') < to_offset('2H')
    Out[10]: True