Skip to content

Commit

Permalink
detect when coming from an arrow backed pandas Series (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasdavis authored Jan 23, 2024
1 parent 7a9cb8a commit 7c5091c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/awkward_pandas/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ExtensionScalarOpsMixin,
set_function_name,
)
from pandas.core.dtypes.dtypes import ArrowDtype
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndex, ABCSeries

from awkward_pandas.dtype import AwkwardDtype
Expand All @@ -34,12 +35,13 @@ def __init__(self, data: Any) -> None:
pass to awkward to generate the internal array. If a JSON string,
parse it using awkward.
"""

self._dtype = AwkwardDtype()
if isinstance(data, type(self)):
self._data = data._data
elif isinstance(data, ak.Array):
self._data = data
elif hasattr(data, "dtype") and isinstance(data.dtype, ArrowDtype):
self._data = ak.from_arrow(data._pa_array)
elif isinstance(data, dict):
self._data = ak.Array(data)
elif isinstance(data, str):
Expand Down

0 comments on commit 7c5091c

Please sign in to comment.