code: def lowpass(data, freq, df, corners=4, zerophase=False):
      
      fe = 0.5 * df
      f = freq / fe
      # raise for some bad scenarios
      if f > 1:
          f = 1.0
          msg = "Selected corner frequency is above Nyquist. " + \
                "Setting Nyquist as high corner."
          warnings.warn(msg)
      z, p, k = iirfilter(corners, f, btype='lowpass', ftype='butter',
                          output='zpk')
      sos = zpk2sos(z, p, k)
      if zerophase:
          firstpass = sosfilt(sos, data)
          return sosfilt(sos, firstpass[::-1])[::-1]
      else:
          return sosfilt(sos, data)
docs: Butterworth-Lowpass Filter.
  
      Filter data removing data over certain frequency ``freq`` using ``corners``
      corners.
      The filter uses :func:`scipy.signal.iirfilter` (for design)
      and :func:`scipy.signal.sosfilt` (for applying the filter).
  
      :type data: numpy.ndarray
      :param data: Data to filter.
      :param freq: Filter corner frequency.
      :param df: Sampling rate in Hz.
      :param corners: Filter corners / order.
      :param zerophase: If True, apply filter once forwards and once backwards.
          This results in twice the number of corners but zero phase shift in
          the resulting filtered trace.
      :return: Filtered data.