Closed
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.
Reporter: Marlene Mhangami
Assignee: Joris Van den Bossche / @jorisvandenbossche
PRs and other links:
Note: This issue was originally created as ARROW-10863. Please see the migration documentation for further details.
Activity
asfimport commentedon Dec 10, 2020
Joris Van den Bossche / @jorisvandenbossche:
[~marlene_zw] thanks for the report!
This was clearly not tested, as the
to_pandasmethod in general doesn't seem to be working for any ExtensionType (so not just for the pandas interval type). Will take a look at it.asfimport commentedon Dec 10, 2020
Marlene Mhangami:
Awesome @jorisvandenbossche! Glad it was helpful :D
asfimport commentedon Dec 15, 2020
Antoine Pitrou / @pitrou:
Issue resolved by pull request 8887
#8887