class_docstr: Dynamic Instruments Filter Abstract class to filter a series of certain features
  
  Filters should provide parameters:
  
  - filter start time
  - filter end time
  - filter rule
  
  Override __init__ to assign a certain rule to filter the series.
  
  Override _getFilterSeries to use the rule to filter the series and get a dict of {inst => series}, or override filter_main for more advanced series filter rule
class_docstr_tok: ["Dynamic","Instruments","Filter","Abstract","class","to","filter","a","series","of","certain","features","Filters","should","provide","parameters",":","-","filter","start","time","-","filter","end","time","-","filter","rule","Override","__init__","to","assign","a","certain","rule","to","filter","the","series",".","Override","_getFilterSeries","to","use","the","rule","to","filter","the","series","and","get","a","dict","of","{","inst","=",">","series","}",",","or","override","filter_main","for","more","advanced","series","filter","rule"]
docstr: Convert the timestamp series to a list of tuple (timestamp, timestamp) indicating a continuous range of TRUE.
  
  Parameters
  ----------
  timestamp_series: pd.Series
      the series of bool value after being filtered.
  
  Returns
  ----------
  list
      the list of tuple (timestamp, timestamp).
docstr_tok: ["Convert","the","timestamp","series","to","a","list","of","tuple","(","timestamp",",","timestamp",")","indicating","a","continuous","range","of","TRUE",".","Parameters","--","--","--","--","--","timestamp_series",":","pd.Series","the","series","of","bool","value","after","being","filtered",".","Returns","--","--","--","--","--","list","the","list","of","tuple","(","timestamp",",","timestamp",")","."]
code: def _toTimestamp(self, timestamp_series):
      """Convert the timestamp series to a list of tuple (timestamp, timestamp) indicating a continuous range of TRUE.
  
      Parameters
      ----------
      timestamp_series: pd.Series
          the series of bool value after being filtered.
  
      Returns
      ----------
      list
          the list of tuple (timestamp, timestamp).
      """
      # sort the timestamp_series according to the timestamps
      timestamp_series.sort_index()
      timestamp = []
      _lbool = None
      _ltime = None
      for _ts, _bool in timestamp_series.items():
          # there is likely to be NAN when the filter series don't have the
          # bool value, so we just change the NAN into False
          if _bool == np.nan:
              _bool = False
          if _lbool is None:
              _cur_start = _ts
              _lbool = _bool
              _ltime = _ts
              continue
          if (_lbool, _bool) == (True, False):
              if _cur_start:
                  timestamp.append((_cur_start, _ltime))
          elif (_lbool, _bool) == (False, True):
              _cur_start = _ts
          _lbool = _bool
          _ltime = _ts
      if _lbool:
          timestamp.append((_cur_start, _ltime))
      return timestamp
  
imports: from __future__ import print_function
  from abc import abstractmethod
  import re
  import pandas
  import numpy
  import abc
  from .data import Cal, DatasetD
label_desc: Use image node_id 5 for calling the SeriesDFilter obj's underlying member method code with example usage: obj._toTimestamp(timestamp_series) and returns: timestamp