code: def apply_filter(df, filter_query):
      """
      Apply a filter query from dash.datable to a pandas.DataFrame (source code : Dash documentation)
  
      Parameters
      ----------
      df : pandas.DataFrame
          dataFrame to be filtered
      filter_query : dcc.datatable.filter_query
          query from dcc.datatable to apply to the DataFrame
  
      Returns
      -------
      pandas.DataFrame
  
      """
      filtering_expressions = filter_query.split(" && ")
      for filter_part in filtering_expressions:
          col_name, operator, filter_value = split_filter_part(
              filter_part
          )
          if operator in ("eq", "ne", "lt", "le", "gt", "ge"):
              # these operators match pandas series operator method names
              df = df.loc[getattr(df[col_name], operator)(filter_value)]
          elif operator == "contains":
              df = df.loc[df[col_name].str.contains(filter_value)]
          elif operator == "datestartswith":
              # this is a simplification of the front-end filtering logic,
              # only works with complete fields in standard format
              df = df.loc[df[col_name].str.startswith(filter_value)]
      return df
  
imports: import pandas
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: apply_filter(df, filter_query) and returns: df