Elastic Search to Pandas Dataframe
Project description
elastic_helper
Two simple functions
- One used to convert an elastic search collection into a dataframe. See the code for the various parameters.
- One used to convert a dataframe into an elastic search collection
Installation
pip install elastic-helper
the pypi page (https://pypi.org/project/elastic-helper/):
Example Elastic To Pandas
Parameters
- es -- The elastic connection object
- index -- The elastic index
- query -- (optional) The elastic query in lucene format Example: "module: *"
- start -- (optional) The time range start if any
- end -- (optional) The time range start if any
- timestampfield -- (optional) The timestamp field used by the start and stop parameters
- datecolumns -- (optional) A collection of columns that must be converted to dates
- scrollsize -- (optional) The size of the scroll to use
- size -- (optional) The maximum number of records to retrieve
- _source -- (optional) The fields to retrieve
from elastic_helper import es_helper
dataframe=es_helper.elastic_to_dataframe(es,index="docker_stats*"
,_source=['read', 'cpu_percent', 'name']
,datecolumns=["read"]
,timestampfield="read"
,start=datetime.now()-timedelta(hours=1)
,end=datetime.now())
Example Pandas To Elastic
- Use an _index column in the dataframe to specify the target index
- Use an _id column in the dataframe to specify the id
from elastic_helper import es_helper
es_helper.dataframe_to_elastic(es,my_df)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
elastic_helper-1.2.4.tar.gz
(5.6 kB
view details)
File details
Details for the file elastic_helper-1.2.4.tar.gz
.
File metadata
- Download URL: elastic_helper-1.2.4.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3da2fd79c1ecfb4d9587e4ba214423a32218575f940249a2a6e9e40d70774c64 |
|
MD5 | e6c1b665de800ab6c73f3326018ae655 |
|
BLAKE2b-256 | 905bfe0cf2292d6e7bcc3ca0571ed550a74eef0cecd0715500890df6234a7762 |