You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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}
The text was updated successfully, but these errors were encountered: