How to save pandas DataFrame to Elasticsearch?

1,514 views
Skip to first unread message

G_will

unread,
Jul 27, 2015, 10:11:55 AM7/27/15
to pyd...@googlegroups.com
How to save pandas DataFrame to Elasticsearch?

Here is my solution:

        l = df.T.to_dict().values()
        for d in l:
            # index d into Elasticsearch

But, It always make errors, something like float('nan'), it will raise Exception, and NaTType, it can be convert to a json field.

Is there a better way to save pandas DataFrame to Elasticsearch?


Chris Withers

unread,
Jul 28, 2015, 9:02:28 AM7/28/15
to pyd...@googlegroups.com
I'd suggest having a look at the "Extending JSONEncoder" section in
https://docs.python.org/2/library/json.html#.

There's also a few answers on StackOverflow that will help you...

Chris

Reply all
Reply to author
Forward
0 new messages