You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "HyukjinKwon (via GitHub)" <gi...@apache.org> on 2023/01/29 05:45:37 UTC

[GitHub] [arrow] HyukjinKwon commented on a diff in pull request #14547: ARROW-17832: [Python] Construct MapArray from sequence of dicts (instead of list of tuples)

HyukjinKwon commented on code in PR #14547:
URL: https://github.com/apache/arrow/pull/14547#discussion_r1089871427


##########
python/pyarrow/tests/test_array.py:
##########
@@ -991,6 +991,16 @@ def test_map_labelled():
     assert len(arr) == 2
 
 
+def test_map_from_dict():
+    # ARROW-17832
+    tup_arr = pa.array([[('a', 1), ('b', 2)], [('c', 3)]],
+                       pa.map_(pa.string(), pa.int64()))
+    dict_arr = pa.array([{'a': 1, 'b': 2}, {'c': 3}],

Review Comment:
   Thanks for this fix. Just had a quick followup question though. Should the nested dict work too? e.g.)
   
   ```python
   import pyarrow as pa
   pa.array([[{'a': 1, 'b': 2}, {'c': 3}]], pa.list_(pa.map_(pa.string(), pa.int64())))
   ```
   
   It currently fails w/
   
   ```
   pyarrow.lib.ArrowTypeError: Could not convert {'a': 1, 'b': 2} with type dict: was not a sequence or recognized null for conversion to list type
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org