def filter_data(df, date_from=None, date_to=None, countries=[]):
    """filter covid data
    Filter covid data in pandas dataframe format
    with the time periods and countries provided.

    Parameters
    ----------
    df : pandas dataframe
        The covid dataframe to filter
    date_from : str, optional
        Start date of the data range with format 'YYYY-MM-DD'.
        By default 'None' is used to represent earliest date available
    date_to : str, optional
        End date of data range with format 'YYYY-MM-DD'.
        By default 'None' is used to represent latest date available
    countries : list, optional
        List of target country names.
        By default 'None' is used for Canada plus United States, United Kingdom, Germany, Singapore.

    Returns
    -------
    pandas.DataFrame
        Pandas dataframe of the selected covid data .

    Examples
    --------
    >>> get_data(date_from="2022-01-01",
                date_to="2022-01-07",
                location=["Canada", "United States"])
    """

    query = "@date_from <= date <= @date_to"

    if date_from is None:
        date_from = df["date"].min()

    if date_to is None:
        date_to = df["date"].max()

    if len(countries) > 0:
        query += " and location in @countries"
    print(len(countries))
    print(query)
    df = df.query(query)

    return df.copy()