Skip to content

Create to_elastic method #28895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kDmartel opened this issue Oct 10, 2019 · 1 comment
Closed

Create to_elastic method #28895

kDmartel opened this issue Oct 10, 2019 · 1 comment

Comments

@kDmartel
Copy link

kDmartel commented Oct 10, 2019

Code Sample, a copy-pastable example if possible

Problem description

Create method to export a pandas dataframe data to elasticsearch json format like to_excel, to_csv, to_sql methods.

Input

df : pandas dataframe
index : str : elasticsearch index
type : str : elasticsearch type
EX :
df.head()
Name Age Weight
0 Kevin 26 94
1 Marc 32 70
2 Louis 35 80

index = 'personnes'

type = 'homme'

Usage

df.to_elastic(file_path, 'index'=index, 'type'=type)

Expected Output

{"index":{"_index": "personnes","_type":"homme","_id":1}}
{"fields" : {"Name" : "Kevin","Age" : 26,"Weight" : 94}
{"index" :{"_index": "personnes","_type":"homme","_id":2}}
{"fields" : {"Name" : "Marx","Age" : 32,"Weight" : 70}
{"index" :{"_index": "personnes","_type":"homme","_id":3}}
{"fields" : {"Name" : "Louis","Age" : 35,"Weight" : 80}

@mroeschke
Copy link
Member

Duplicate discussion in #23315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants