You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Joris Van den Bossche (Jira)" <ji...@apache.org> on 2022/09/23 16:50:00 UTC
[jira] [Created] (ARROW-17834) [Python] Allow creating ExtensionArray through pa.array(..) constructor
Joris Van den Bossche created ARROW-17834:
---------------------------------------------
Summary: [Python] Allow creating ExtensionArray through pa.array(..) constructor
Key: ARROW-17834
URL: https://issues.apache.org/jira/browse/ARROW-17834
Project: Apache Arrow
Issue Type: Improvement
Components: Python
Reporter: Joris Van den Bossche
Currently, creating an ExtensionArray from a python sequence (or numpy array, ..) requires the following:
{code:python}
from pyarrow.tests.test_extension_type import IntegerType
storage_array = pa.array([1, 2, 3])
ext_arr = pa.ExtensionArray.from_storage(IntegerType(), storage_array)
{code}
While doing this directly in {{pa.array(..)}} doesn't work:
{code:python}
>>> pa.array([1, 2, 3], type=IntegerType())
ArrowNotImplementedError: extension
{code}
I think it should be possible to basically to the ExtensionArray.from_storage under the hood in {{pa.array(..)}} when the specified type is an extension type?
I think this should also enable converting from a pandas DataFrame (with a column with matching storage values) to a Table with a specified schema that includes an extension type. Like:
{code}
df = pd.DataFrame({'a': [1, 2, 3]})
pa.table(df, schema=pa.schema([('a', IntegerType())]))
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)