Esempio n. 1
0
    def __init__(
        self,
        es_client: Optional[Union[str, List[str], Tuple[str, ...],
                                  "Elasticsearch"]] = None,
        es_index_pattern: Optional[str] = None,
        columns: Optional[List[str]] = None,
        es_index_field: Optional[str] = None,
        _query_compiler: Optional[QueryCompiler] = None,
    ) -> None:
        """
        pandas.DataFrame/Series like API that proxies into Elasticsearch index(es).

        Parameters
        ----------
        client : elasticsearch.Elasticsearch
            A reference to a Elasticsearch python client
        """
        if _query_compiler is None:
            _query_compiler = QueryCompiler(
                client=es_client,
                index_pattern=es_index_pattern,
                display_names=columns,
                index_field=es_index_field,
            )
        self._query_compiler = _query_compiler
Esempio n. 2
0
 def __init__(
     self,
     by: List[str],
     query_compiler: "QueryCompiler",
     dropna: bool = True,
 ) -> None:
     self._query_compiler: "QueryCompiler" = QueryCompiler(to_copy=query_compiler)
     self._dropna: bool = dropna
     self._by: List[str] = by
Esempio n. 3
0
    def test_init(self):
        # Construct empty DataFrame (throws)
        with pytest.raises(ValueError):
            ed.DataFrame()

        # Construct invalid DataFrame (throws)
        with pytest.raises(ValueError):
            ed.DataFrame(es_client=ES_TEST_CLIENT)

        # Construct invalid DataFrame (throws)
        with pytest.raises(ValueError):
            ed.DataFrame(es_index_pattern=FLIGHTS_INDEX_NAME)

        # Good constructors
        ed.DataFrame(ES_TEST_CLIENT, FLIGHTS_INDEX_NAME)
        ed.DataFrame(es_client=ES_TEST_CLIENT, es_index_pattern=FLIGHTS_INDEX_NAME)

        qc = QueryCompiler(client=ES_TEST_CLIENT, index_pattern=FLIGHTS_INDEX_NAME)
        ed.DataFrame(_query_compiler=qc)
Esempio n. 4
0
    def __init__(
        self,
        es_client=None,
        es_index_pattern=None,
        columns=None,
        es_index_field=None,
        _query_compiler=None,
    ):
        """
        pandas.DataFrame/Series like API that proxies into Elasticsearch index(es).

        Parameters
        ----------
        client : elasticsearch.Elasticsearch
            A reference to a Elasticsearch python client
        """
        if _query_compiler is None:
            _query_compiler = QueryCompiler(
                client=es_client,
                index_pattern=es_index_pattern,
                display_names=columns,
                index_field=es_index_field,
            )
        self._query_compiler = _query_compiler