terrier-org / pyterrier

A Python framework for performing information retrieval experiments, building on http://terrier.org/

Home Page:https://pyterrier.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pt.apply.query() raises exception if the query column does not exist

cmacdonald opened this issue · comments

    def push_queries(df: pd.DataFrame, keep_original:bool=False, inplace:bool=False) -> pd.DataFrame:
        """
            Changes a dataframe such that the "query" column becomes "query_0", and any
            "query_0" columns becames "query_1" etc.
    
            Arguments:
                df: Dataframe with a "query" column
                keep_original: if True, the query column is also left unchanged. Useful for client code.
                    Defaults to False.
                inplace: if False, a copy of the dataframe is returned. If True, changes are made to the
                    supplied dataframe. Defaults to False.
        """
        if "query" not in df.columns:
>           raise TypeError("Expected a query column, but found %s" % df.columns)
E           TypeError: Expected a query column, but found Index(['qid', 'docno', 'docid', 'rank', 'critique', 'critique_rep'], dtype='object')