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

[Python] ExtensionArray.to_pandas not working

    XMLWordPrintableJSON

Details

    Description

      Hi!

      When I create a pandas interval series and then convert it into a pyarrow array and then try to convert that pyarrow array back to pandas I'm getting an attribute error. The error says that Series object has no attribute `to_pandas`.

      I've added the code that produces the error below. 

      // code placeholder
      
      In [14]: x = pd.Series([pd.Interval(0, 1), pd.Interval(2, 3), pd.Interval(3, 4)])
      
      In [15]: y = pa.Array.from_pandas(x)
      
      In [16]: y.type
      Out[17]: ArrowIntervalType(extension<pandas.interval>)
      
      In [17]: y.to_pandas()
      ---------------------------------------------------------------------------
      AttributeError                            Traceback (most recent call last)
      <ipython-input-17-48c5b189df56> in <module>
      ----> 1 y.to_pandas()~/compose/etc/conda/cuda_10.2/envs/rapids/lib/python3.7/site-packages/pyarrow/array.pxi in pyarrow.lib._PandasConvertible.to_pandas()~/compose/etc/conda/cuda_10.2/envs/rapids/lib/python3.7/site-packages/pyarrow/array.pxi in pyarrow.lib.ExtensionArray._to_pandas()~/compose/etc/conda/cuda_10.2/envs/rapids/lib/python3.7/site-packages/pandas/core/generic.py in __getattr__(self, name)
         5128             if self._info_axis._can_hold_identifiers_and_holds_name(name):
         5129                 return self[name]
      -> 5130             return object.__getattribute__(self, name)
         5131 
         5132     def __setattr__(self, name: str, value) -> None:AttributeError: 'Series' object has no attribute 'to_pandas'
      
      
      

      It would be great tp have a method to convert from a pyarrow interval array directly into a pandas series. 

      Attachments

        Activity

          People

            jorisvandenbossche Joris Van den Bossche
            marlene_zw Marlene Mhangami
            Votes:
            0 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 - 3h 50m
                3h 50m