如何在Python熊猫中为以下代码编写单元测试用例

时间:2019-05-11 07:32:41

标签: python pandas dataframe python-unittest testcase

如何为以下方法编写单元测试用例?

def aggregate_ts(ts,orig_frequency,new_frequency):
  if orig_frequency <= new_frequency:
    # print(ts.name ,new_frequency)      
    if ts.dtypes != 'object':   
      ts_new = ts.resample(str(new_frequency)+ 's').first().interpolate()   
    else:      
      ts_new = ts.resample(str(new_frequency)+ 's').first()   
  else:
    # print(ts.name,orig_frequency)
    if ts.dtypes != 'object':
      ts_new = ts.resample(str(orig_frequency)+ 's'0.first().interpolate()
    else:
      ts_new = ts.resample(str(orig_frequency)+'s').first()   
  # print(ts_new.name, ts_new.dtypes)
  return ts_new

0 个答案:

没有答案