Skip to content

ValueError when using opensearch.index_df with documents with an array field #1413

@oeN

Description

@oeN

Describe the bug

When I try to index a data frame that contains documents with array fields I receive this error:

.../awswrangler/opensearch/_write.py", line 82, in <dictcomp>
    yield {k: _deserialize(v) for k, v in document.items() if notna(v)}
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

How to Reproduce

Code that triggers the error:

df = pd.DataFrame([
    {"_id": "1", "name": "John", "tags": ['foo', 'bar']}, 
    {"_id": "2", "name": "George", "tags": ['bar', 'baz']}, 
    {"_id": "3", "name": "Julia", "tags": ['bar']}
])
wr.opensearch.index_df(client=client,df=df,index='test_index_for_array')

Expected behavior

No response

Your project

No response

Screenshots

No response

OS

Mac

Python version

3.9.12

AWS DataWrangler version

2.16.0

Additional context

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions