You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@arrow.apache.org by Sandy Ryza <sa...@gmail.com> on 2020/05/29 21:18:20 UTC

check whether pandas type is convertible to arrow type

Hi all,

If I have a pandas dtype and an arrow type, is there a pyarrow API that
allows me to check whether the pandas dtype is convertible to the arrow
type?

It seems like "arrow_type.to_pandas_dtype() == pandas_dtype" would work in
most cases, because pandas dtypes tend to be at least as wide as equivalent
arrow types, but I'm wondering whether there's something more principled.

Any help much appreciated,
Sandy

Re: check whether pandas type is convertible to arrow type

Posted by Wes McKinney <we...@gmail.com>.
I don't think there is specifically (one could be added in theory). Is
the goal to determine whether `pyarrow.array(pandas_object)` will
succeed or not, or something else? Since a lot of pandas data is
opaquely represented with object dtype it can be tricky unless you
want to go to the expense of using `pandas.lib.infer_dtype` to
determine the effective logical type of the values.

On Fri, May 29, 2020 at 4:18 PM Sandy Ryza <sa...@gmail.com> wrote:
>
> Hi all,
>
> If I have a pandas dtype and an arrow type, is there a pyarrow API that allows me to check whether the pandas dtype is convertible to the arrow type?
>
> It seems like "arrow_type.to_pandas_dtype() == pandas_dtype" would work in most cases, because pandas dtypes tend to be at least as wide as equivalent arrow types, but I'm wondering whether there's something more principled.
>
> Any help much appreciated,
> Sandy
>