code: def filter_ts(df: pd.DataFrame, tss, n_rows=1):
      """
      This method triggers only for timeseries datasets.
  
      It returns a dataframe that filters out all but the first ``n_rows`` per group.
      """  # noqa
      if tss.is_timeseries:
          gby = tss.group_by
          if gby is None:
              df = df.iloc[[0]]
          else:
              ndf = pd.DataFrame(columns=df.columns)
              grouped = df.groupby(by=tss.group_by)
              for group, subdf in grouped:
                  if group != "__default":
                      ndf = pd.concat([ndf, subdf.iloc[:n_rows]])
              df = ndf
      return df
  
file_path: lightwood/lightwood/helpers/ts.py
imports: from typing import Tuple, Dict
  from datetime import datetime
  import numpy
  import pandas
label_desc: Use image node_id 8 for calling a global function with example usage: filter_ts(df, tss, n_rows) and returns: df