Re: Creating a pa.Array of struct type

2017-12-19 Thread Li Jin
Thanks Wes! On Mon, Dec 18, 2017 at 6:25 PM, Wes McKinney wrote: > hi Li, > > You want to use StructArray.from_arrays > > a_values = pa.array([1]) > b_values = pa.array([2]) > struct_values = pa.StructArray.from_arrays(['a', 'b'], [a_values, > b_values]) > > In [4]: struct_values > Out[4]: > >

Re: Creating a pa.Array of struct type

2017-12-18 Thread Wes McKinney
hi Li, You want to use StructArray.from_arrays a_values = pa.array([1]) b_values = pa.array([2]) struct_values = pa.StructArray.from_arrays(['a', 'b'], [a_values, b_values]) In [4]: struct_values Out[4]: [ {'b': 2, 'a': 1} ] You can find other examples in the Python test suite. I would be ve

Re: Creating a pa.Array of struct type

2017-12-18 Thread Li Jin
Also tried this: >>> pa.array([{'a': 1.0, 'b': 2.0}], pa.struct([pa.field('a', pa.float64()), pa.field('b', pa.float64())])) Traceback (most recent call last): File "", line 1, in File "array.pxi", line 56, in pyarrow.lib.array File "error.pxi", line 85, in pyarrow.lib.check_status pya

Creating a pa.Array of struct type

2017-12-18 Thread Li Jin
Hey folks, What's best way to create a pyarrow.Array of struct? I tried to create a pyarrow.Array from a pd.Series of dict but doesn't seem to work (0.7.1): >>> s 0{'a': 1, 'b': 2} Name: stats, dtype: object >>> pa.Array.from_pandas(s) Traceback (most recent call last): File "", line 1