Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-7218

[Python] Conversion from boolean numpy scalars not working

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.0
    • Python

    Description

      In general, we are fine to accept a list of numpy scalars:

      In [12]: type(list(np.array([1, 2]))[0])                                                                                                                                                                           
      Out[12]: numpy.int64
      
      In [13]: pa.array(list(np.array([1, 2])))                                                                                                                                                                          
      Out[13]: 
      <pyarrow.lib.Int64Array object at 0x7f51a493e2e8>
      [
        1,
        2
      ]
      

      But for booleans, this doesn't work:

      In [14]: pa.array(list(np.array([True, False])))                                                                                                                                                                   
      ---------------------------------------------------------------------------
      ArrowInvalid                              Traceback (most recent call last)
      <ipython-input-14-0d82cdce82e8> in <module>
      ----> 1 pa.array(list(np.array([True, False])))
      
      ~/scipy/repos/arrow/python/pyarrow/array.pxi in pyarrow.lib.array()
      
      ~/scipy/repos/arrow/python/pyarrow/array.pxi in pyarrow.lib._sequence_to_array()
      
      ~/scipy/repos/arrow/python/pyarrow/array.pxi in pyarrow.lib._ndarray_to_array()
      
      ArrowInvalid: Could not convert True with type numpy.bool_: tried to convert to boolean
      

      Attachments

        Issue Links

          Activity

            People

              kszucs Krisztian Szucs
              jorisvandenbossche Joris Van den Bossche
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m