You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by Suhail Razzak <su...@gmail.com> on 2019/11/15 21:21:32 UTC

Creating arrays from existing arrays in Cython

Hi,

I'm trying to create arrays from an existing array but I'm not sure how
exactly to do it. I tried using the ArrayBuilder class, but I keep getting
compiler errors when trying to instantiate one...

So I have a couple questions then:

1. How would I instantiate and use an ArrayBuilder class?
2. Would I build it the same as the C++ way? I.e. builder.get().Append()
and then builder.get().Finish(new_array)?
3. How can I access the underlying data of an Array? I keep getting an
IndexError when trying array.get().data()[i]

I'm kind of new to Cython too, sorry if this seems dumb.

Thanks,
Suhail

Re: Creating arrays from existing arrays in Cython

Posted by Suhail Razzak <su...@gmail.com>.
Hi Micah,

I was trying to create an Int64Builder class but kept getting a type
identifier error. So, I did a bit of digging and realized I was looking at
the latest commit of libarrow.pxd on GitHub which wasn't actually released
as part of 0.15.1.

Thanks for your help anyways!

Suhail

On Sat, Nov 16, 2019 at 11:20 PM Micah Kornfield <em...@gmail.com>
wrote:

> Hi Suhail,
> I'm not sure there are any convenience function to initialize an
> ArrayBuilder class from an existing Array.  But I imagine you should be
> able to use the cython definitions in
> "python//pyarrow/includes/libarrow.pxd" and use it in the way you
> describe.  It might help if you can provide a pointer to minimal code
> sample.
>
> Thanks,
> Micah
>
>
>
>
>
> On Fri, Nov 15, 2019 at 1:21 PM Suhail Razzak <su...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I'm trying to create arrays from an existing array but I'm not sure how
> > exactly to do it. I tried using the ArrayBuilder class, but I keep
> getting
> > compiler errors when trying to instantiate one...
> >
> > So I have a couple questions then:
> >
> > 1. How would I instantiate and use an ArrayBuilder class?
> > 2. Would I build it the same as the C++ way? I.e. builder.get().Append()
> > and then builder.get().Finish(new_array)?
> > 3. How can I access the underlying data of an Array? I keep getting an
> > IndexError when trying array.get().data()[i]
> >
> > I'm kind of new to Cython too, sorry if this seems dumb.
> >
> > Thanks,
> > Suhail
> >
>


-- 
Regards,

Suhail

Re: Creating arrays from existing arrays in Cython

Posted by Micah Kornfield <em...@gmail.com>.
Hi Suhail,
I'm not sure there are any convenience function to initialize an
ArrayBuilder class from an existing Array.  But I imagine you should be
able to use the cython definitions in
"python//pyarrow/includes/libarrow.pxd" and use it in the way you
describe.  It might help if you can provide a pointer to minimal code
sample.

Thanks,
Micah





On Fri, Nov 15, 2019 at 1:21 PM Suhail Razzak <su...@gmail.com>
wrote:

> Hi,
>
> I'm trying to create arrays from an existing array but I'm not sure how
> exactly to do it. I tried using the ArrayBuilder class, but I keep getting
> compiler errors when trying to instantiate one...
>
> So I have a couple questions then:
>
> 1. How would I instantiate and use an ArrayBuilder class?
> 2. Would I build it the same as the C++ way? I.e. builder.get().Append()
> and then builder.get().Finish(new_array)?
> 3. How can I access the underlying data of an Array? I keep getting an
> IndexError when trying array.get().data()[i]
>
> I'm kind of new to Cython too, sorry if this seems dumb.
>
> Thanks,
> Suhail
>