You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/04/17 21:47:58 UTC
arrow git commit: ARROW-825: [Python] Rename pyarrow.from_pylist to
pyarrow.array, test on tuples
Repository: arrow
Updated Branches:
refs/heads/master 7238d544c -> 84d725ba2
ARROW-825: [Python] Rename pyarrow.from_pylist to pyarrow.array, test on tuples
The idea is to make this function more semantically analogous to `numpy.array` -- convert to native data structure with optional explicit type.
Author: Wes McKinney <we...@twosigma.com>
Closes #552 from wesm/ARROW-825 and squashes the following commits:
5d69c70 [Wes McKinney] Update test_jemalloc after ARROW-830
c25fdee [Wes McKinney] Update docstring
3a284b7 [Wes McKinney] Rename pyarrow.from_pylist to pyarrow.array, test on tuples
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/84d725ba
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/84d725ba
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/84d725ba
Branch: refs/heads/master
Commit: 84d725ba2610c778af75060d1c69a4ff8b2a2efc
Parents: 7238d54
Author: Wes McKinney <we...@twosigma.com>
Authored: Mon Apr 17 17:47:51 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Mon Apr 17 17:47:51 2017 -0400
----------------------------------------------------------------------
python/doc/source/api.rst | 5 +-
python/doc/source/install.rst | 17 +++---
python/pyarrow/__init__.py | 2 +-
python/pyarrow/_array.pyx | 69 ++++++++++++-----------
python/pyarrow/parquet.py | 4 +-
python/pyarrow/tests/test_array.py | 18 +++---
python/pyarrow/tests/test_convert_builtin.py | 60 +++++++++++---------
python/pyarrow/tests/test_jemalloc.py | 6 +-
python/pyarrow/tests/test_parquet.py | 2 +-
python/pyarrow/tests/test_scalars.py | 14 ++---
python/pyarrow/tests/test_table.py | 40 ++++++-------
11 files changed, 123 insertions(+), 114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/doc/source/api.rst
----------------------------------------------------------------------
diff --git a/python/doc/source/api.rst b/python/doc/source/api.rst
index 1b7b9bd..92e248b 100644
--- a/python/doc/source/api.rst
+++ b/python/doc/source/api.rst
@@ -83,12 +83,13 @@ Scalar Value Types
StringValue
FixedSizeBinaryValue
-Array Types
------------
+Array Types and Constructors
+----------------------------
.. autosummary::
:toctree: generated/
+ array
Array
NullArray
NumericArray
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/doc/source/install.rst
----------------------------------------------------------------------
diff --git a/python/doc/source/install.rst b/python/doc/source/install.rst
index 16d19ef..278b466 100644
--- a/python/doc/source/install.rst
+++ b/python/doc/source/install.rst
@@ -90,7 +90,7 @@ using the default system install location will work, but for now we are being
explicit:
.. code-block:: bash
-
+
export ARROW_HOME=$HOME/local
Now, we build Arrow:
@@ -98,18 +98,18 @@ Now, we build Arrow:
.. code-block:: bash
cd arrow/cpp
-
+
mkdir dev-build
cd dev-build
-
+
cmake -DCMAKE_INSTALL_PREFIX=$ARROW_HOME ..
-
+
make
-
+
# Use sudo here if $ARROW_HOME requires it
make install
-To get the optional Parquet support, you should also build and install
+To get the optional Parquet support, you should also build and install
`parquet-cpp <https://github.com/apache/parquet-cpp/blob/master/README.md>`_.
Install `pyarrow`
@@ -138,10 +138,10 @@ Install `pyarrow`
.. code-block:: python
-
+
In [1]: import pyarrow
- In [2]: pyarrow.from_pylist([1,2,3])
+ In [2]: pyarrow.array([1,2,3])
Out[2]:
<pyarrow.array.Int64Array object at 0x7f899f3e60e8>
[
@@ -149,4 +149,3 @@ Install `pyarrow`
2,
3
]
-
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/__init__.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py
index 3db2a4f..87f2352 100644
--- a/python/pyarrow/__init__.py
+++ b/python/pyarrow/__init__.py
@@ -38,7 +38,7 @@ from pyarrow._array import (null, bool_,
DataType, FixedSizeBinaryType,
Field, Schema, schema,
Array, Tensor,
- from_pylist,
+ array,
from_numpy_dtype,
NullArray,
NumericArray, IntegerArray, FloatingPointArray,
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/_array.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/_array.pyx b/python/pyarrow/_array.pyx
index 99ff6f2..e41380d 100644
--- a/python/pyarrow/_array.pyx
+++ b/python/pyarrow/_array.pyx
@@ -835,6 +835,42 @@ cdef maybe_coerce_datetime64(values, dtype, DataType type,
return values, type
+
+def array(object sequence, DataType type=None, MemoryPool memory_pool=None):
+ """
+ Create pyarrow.Array instance from a Python sequence
+
+ Parameters
+ ----------
+ sequence : sequence-like object of Python objects
+ type : pyarrow.DataType, optional
+ If not passed, will be inferred from the data
+ memory_pool : pyarrow.MemoryPool, optional
+ If not passed, will allocate memory from the currently-set default
+ memory pool
+
+ Returns
+ -------
+ array : pyarrow.Array
+ """
+ cdef:
+ shared_ptr[CArray] sp_array
+ CMemoryPool* pool
+
+ pool = maybe_unbox_memory_pool(memory_pool)
+ if type is None:
+ check_status(pyarrow.ConvertPySequence(sequence, pool, &sp_array))
+ else:
+ check_status(
+ pyarrow.ConvertPySequence(
+ sequence, pool, &sp_array, type.sp_type
+ )
+ )
+
+ return box_array(sp_array)
+
+
+
cdef class Array:
cdef init(self, const shared_ptr[CArray]& sp_array):
@@ -936,36 +972,6 @@ cdef class Array:
return box_array(out)
- @staticmethod
- def from_list(object list_obj, DataType type=None,
- MemoryPool memory_pool=None):
- """
- Convert Python list to Arrow array
-
- Parameters
- ----------
- list_obj : array_like
-
- Returns
- -------
- pyarrow.array.Array
- """
- cdef:
- shared_ptr[CArray] sp_array
- CMemoryPool* pool
-
- pool = maybe_unbox_memory_pool(memory_pool)
- if type is None:
- check_status(pyarrow.ConvertPySequence(list_obj, pool, &sp_array))
- else:
- check_status(
- pyarrow.ConvertPySequence(
- list_obj, pool, &sp_array, type.sp_type
- )
- )
-
- return box_array(sp_array)
-
property null_count:
def __get__(self):
@@ -1408,6 +1414,3 @@ cdef object get_series_values(object obj):
result = PandasSeries(obj).values
return result
-
-
-from_pylist = Array.from_list
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/parquet.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/parquet.py b/python/pyarrow/parquet.py
index fef99d5..94ad227 100644
--- a/python/pyarrow/parquet.py
+++ b/python/pyarrow/parquet.py
@@ -295,9 +295,9 @@ class PartitionSet(object):
# Only integer and string partition types are supported right now
try:
integer_keys = [int(x) for x in self.keys]
- dictionary = _array.from_pylist(integer_keys)
+ dictionary = _array.array(integer_keys)
except ValueError:
- dictionary = _array.from_pylist(self.keys)
+ dictionary = _array.array(self.keys)
self._dictionary = dictionary
return dictionary
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/tests/test_array.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py
index a1fe842..7c91785 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -36,12 +36,12 @@ def test_repr_on_pre_init_array():
def test_getitem_NA():
- arr = pa.from_pylist([1, None, 2])
+ arr = pa.array([1, None, 2])
assert arr[1] is pa.NA
def test_list_format():
- arr = pa.from_pylist([[1], None, [2, 3, None]])
+ arr = pa.array([[1], None, [2, 3, None]])
result = fmt.array_format(arr)
expected = """\
[
@@ -55,7 +55,7 @@ def test_list_format():
def test_string_format():
- arr = pa.from_pylist(['', None, 'foo'])
+ arr = pa.array(['', None, 'foo'])
result = fmt.array_format(arr)
expected = """\
[
@@ -67,7 +67,7 @@ def test_string_format():
def test_long_array_format():
- arr = pa.from_pylist(range(100))
+ arr = pa.array(range(100))
result = fmt.array_format(arr, window=2)
expected = """\
[
@@ -83,7 +83,7 @@ def test_long_array_format():
def test_to_pandas_zero_copy():
import gc
- arr = pa.from_pylist(range(10))
+ arr = pa.array(range(10))
for i in range(10):
np_arr = arr.to_pandas()
@@ -93,7 +93,7 @@ def test_to_pandas_zero_copy():
assert sys.getrefcount(arr) == 2
for i in range(10):
- arr = pa.from_pylist(range(10))
+ arr = pa.array(range(10))
np_arr = arr.to_pandas()
arr = None
gc.collect()
@@ -108,14 +108,14 @@ def test_to_pandas_zero_copy():
def test_array_slice():
- arr = pa.from_pylist(range(10))
+ arr = pa.array(range(10))
sliced = arr.slice(2)
- expected = pa.from_pylist(range(2, 10))
+ expected = pa.array(range(2, 10))
assert sliced.equals(expected)
sliced2 = arr.slice(2, 4)
- expected2 = pa.from_pylist(range(2, 6))
+ expected2 = pa.array(range(2, 6))
assert sliced2.equals(expected2)
# 0 offset
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/tests/test_convert_builtin.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_convert_builtin.py b/python/pyarrow/tests/test_convert_builtin.py
index d89a8e0..d25055d 100644
--- a/python/pyarrow/tests/test_convert_builtin.py
+++ b/python/pyarrow/tests/test_convert_builtin.py
@@ -23,25 +23,31 @@ import datetime
import decimal
-class TestConvertList(unittest.TestCase):
+class TestConvertSequence(unittest.TestCase):
+
+ def test_sequence_types(self):
+ arr1 = pa.array([1, 2, 3])
+ arr2 = pa.array((1, 2, 3))
+
+ assert arr1.equals(arr2)
def test_boolean(self):
expected = [True, None, False, None]
- arr = pa.from_pylist(expected)
+ arr = pa.array(expected)
assert len(arr) == 4
assert arr.null_count == 2
assert arr.type == pa.bool_()
assert arr.to_pylist() == expected
def test_empty_list(self):
- arr = pa.from_pylist([])
+ arr = pa.array([])
assert len(arr) == 0
assert arr.null_count == 0
assert arr.type == pa.null()
assert arr.to_pylist() == []
def test_all_none(self):
- arr = pa.from_pylist([None, None])
+ arr = pa.array([None, None])
assert len(arr) == 2
assert arr.null_count == 2
assert arr.type == pa.null()
@@ -49,7 +55,7 @@ class TestConvertList(unittest.TestCase):
def test_integer(self):
expected = [1, None, 3, None]
- arr = pa.from_pylist(expected)
+ arr = pa.array(expected)
assert len(arr) == 4
assert arr.null_count == 2
assert arr.type == pa.int64()
@@ -62,13 +68,13 @@ class TestConvertList(unittest.TestCase):
gc.collect()
bytes_before = pa.total_allocated_bytes()
- pa.from_pylist([1, None, 3, None])
+ pa.array([1, None, 3, None])
gc.collect()
assert pa.total_allocated_bytes() == bytes_before
def test_double(self):
data = [1.5, 1, None, 2.5, None, None]
- arr = pa.from_pylist(data)
+ arr = pa.array(data)
assert len(arr) == 6
assert arr.null_count == 3
assert arr.type == pa.float64()
@@ -76,7 +82,7 @@ class TestConvertList(unittest.TestCase):
def test_unicode(self):
data = [u'foo', u'bar', None, u'ma�ana']
- arr = pa.from_pylist(data)
+ arr = pa.array(data)
assert len(arr) == 4
assert arr.null_count == 1
assert arr.type == pa.string()
@@ -87,7 +93,7 @@ class TestConvertList(unittest.TestCase):
data = [b'foo',
u1.decode('utf-8'), # unicode gets encoded,
None]
- arr = pa.from_pylist(data)
+ arr = pa.array(data)
assert len(arr) == 3
assert arr.null_count == 1
assert arr.type == pa.binary()
@@ -95,7 +101,7 @@ class TestConvertList(unittest.TestCase):
def test_fixed_size_bytes(self):
data = [b'foof', None, b'barb', b'2346']
- arr = pa.from_pylist(data, type=pa.binary(4))
+ arr = pa.array(data, type=pa.binary(4))
assert len(arr) == 4
assert arr.null_count == 1
assert arr.type == pa.binary(4)
@@ -104,12 +110,12 @@ class TestConvertList(unittest.TestCase):
def test_fixed_size_bytes_does_not_accept_varying_lengths(self):
data = [b'foo', None, b'barb', b'2346']
with self.assertRaises(pa.ArrowInvalid):
- pa.from_pylist(data, type=pa.binary(4))
+ pa.array(data, type=pa.binary(4))
def test_date(self):
data = [datetime.date(2000, 1, 1), None, datetime.date(1970, 1, 1),
datetime.date(2040, 2, 26)]
- arr = pa.from_pylist(data)
+ arr = pa.array(data)
assert len(arr) == 4
assert arr.type == pa.date64()
assert arr.null_count == 1
@@ -125,7 +131,7 @@ class TestConvertList(unittest.TestCase):
datetime.datetime(2006, 1, 13, 12, 34, 56, 432539),
datetime.datetime(2010, 8, 13, 5, 46, 57, 437699)
]
- arr = pa.from_pylist(data)
+ arr = pa.array(data)
assert len(arr) == 4
assert arr.type == pa.timestamp('us')
assert arr.null_count == 1
@@ -138,22 +144,22 @@ class TestConvertList(unittest.TestCase):
46, 57, 437699)
def test_mixed_nesting_levels(self):
- pa.from_pylist([1, 2, None])
- pa.from_pylist([[1], [2], None])
- pa.from_pylist([[1], [2], [None]])
+ pa.array([1, 2, None])
+ pa.array([[1], [2], None])
+ pa.array([[1], [2], [None]])
with self.assertRaises(pa.ArrowInvalid):
- pa.from_pylist([1, 2, [1]])
+ pa.array([1, 2, [1]])
with self.assertRaises(pa.ArrowInvalid):
- pa.from_pylist([1, 2, []])
+ pa.array([1, 2, []])
with self.assertRaises(pa.ArrowInvalid):
- pa.from_pylist([[1], [2], [None, [1]]])
+ pa.array([[1], [2], [None, [1]]])
def test_list_of_int(self):
data = [[1, 2, 3], [], None, [1, 2]]
- arr = pa.from_pylist(data)
+ arr = pa.array(data)
assert len(arr) == 4
assert arr.null_count == 1
assert arr.type == pa.list_(pa.int64())
@@ -162,12 +168,12 @@ class TestConvertList(unittest.TestCase):
def test_mixed_types_fails(self):
data = ['a', 1, 2.0]
with self.assertRaises(pa.ArrowException):
- pa.from_pylist(data)
+ pa.array(data)
def test_decimal(self):
data = [decimal.Decimal('1234.183'), decimal.Decimal('8094.234')]
type = pa.decimal(precision=7, scale=3)
- arr = pa.from_pylist(data, type=type)
+ arr = pa.array(data, type=type)
assert arr.to_pylist() == data
def test_decimal_different_precisions(self):
@@ -175,30 +181,30 @@ class TestConvertList(unittest.TestCase):
decimal.Decimal('1234234983.183'), decimal.Decimal('80943244.234')
]
type = pa.decimal(precision=13, scale=3)
- arr = pa.from_pylist(data, type=type)
+ arr = pa.array(data, type=type)
assert arr.to_pylist() == data
def test_decimal_no_scale(self):
data = [decimal.Decimal('1234234983'), decimal.Decimal('8094324')]
type = pa.decimal(precision=10)
- arr = pa.from_pylist(data, type=type)
+ arr = pa.array(data, type=type)
assert arr.to_pylist() == data
def test_decimal_negative(self):
data = [decimal.Decimal('-1234.234983'), decimal.Decimal('-8.094324')]
type = pa.decimal(precision=10, scale=6)
- arr = pa.from_pylist(data, type=type)
+ arr = pa.array(data, type=type)
assert arr.to_pylist() == data
def test_decimal_no_whole_part(self):
data = [decimal.Decimal('-.4234983'), decimal.Decimal('.0103943')]
type = pa.decimal(precision=7, scale=7)
- arr = pa.from_pylist(data, type=type)
+ arr = pa.array(data, type=type)
assert arr.to_pylist() == data
def test_decimal_large_integer(self):
data = [decimal.Decimal('-394029506937548693.42983'),
decimal.Decimal('32358695912932.01033')]
type = pa.decimal(precision=23, scale=5)
- arr = pa.from_pylist(data, type=type)
+ arr = pa.array(data, type=type)
assert arr.to_pylist() == data
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/tests/test_jemalloc.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_jemalloc.py b/python/pyarrow/tests/test_jemalloc.py
index 0a4d8a6..50eb74a 100644
--- a/python/pyarrow/tests/test_jemalloc.py
+++ b/python/pyarrow/tests/test_jemalloc.py
@@ -39,8 +39,8 @@ def test_different_memory_pool():
bytes_before_jemalloc = pa.jemalloc_memory_pool().bytes_allocated()
# it works
- array = pa.from_pylist([1, None, 3, None], # noqa
- memory_pool=pa.jemalloc_memory_pool())
+ array = pa.array([1, None, 3, None], # noqa
+ memory_pool=pa.jemalloc_memory_pool())
gc.collect()
assert pa.total_allocated_bytes() == bytes_before_default
assert (pa.jemalloc_memory_pool().bytes_allocated() >
@@ -56,7 +56,7 @@ def test_default_memory_pool():
old_memory_pool = pa.default_memory_pool()
pa.set_memory_pool(pa.jemalloc_memory_pool())
- array = pa.from_pylist([1, None, 3, None]) # noqa
+ array = pa.array([1, None, 3, None]) # noqa
pa.set_memory_pool(old_memory_pool)
gc.collect()
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/tests/test_parquet.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_parquet.py b/python/pyarrow/tests/test_parquet.py
index fc35781..268e87a 100644
--- a/python/pyarrow/tests/test_parquet.py
+++ b/python/pyarrow/tests/test_parquet.py
@@ -47,7 +47,7 @@ def test_single_pylist_column_roundtrip(tmpdir):
for dtype in [int, float]:
filename = tmpdir.join('single_{}_column.parquet'
.format(dtype.__name__))
- data = [pa.from_pylist(list(map(dtype, range(5))))]
+ data = [pa.array(list(map(dtype, range(5))))]
table = pa.Table.from_arrays(data, names=('a', 'b'))
pq.write_table(table, filename.strpath)
table_read = pq.read_table(filename.strpath)
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/tests/test_scalars.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_scalars.py b/python/pyarrow/tests/test_scalars.py
index df2a898..149973b 100644
--- a/python/pyarrow/tests/test_scalars.py
+++ b/python/pyarrow/tests/test_scalars.py
@@ -29,7 +29,7 @@ class TestScalars(unittest.TestCase):
pa.NAType()
def test_bool(self):
- arr = pa.from_pylist([True, None, False, None])
+ arr = pa.array([True, None, False, None])
v = arr[0]
assert isinstance(v, pa.BooleanValue)
@@ -39,7 +39,7 @@ class TestScalars(unittest.TestCase):
assert arr[1] is pa.NA
def test_int64(self):
- arr = pa.from_pylist([1, 2, None])
+ arr = pa.array([1, 2, None])
v = arr[0]
assert isinstance(v, pa.Int64Value)
@@ -49,7 +49,7 @@ class TestScalars(unittest.TestCase):
assert arr[2] is pa.NA
def test_double(self):
- arr = pa.from_pylist([1.5, None, 3])
+ arr = pa.array([1.5, None, 3])
v = arr[0]
assert isinstance(v, pa.DoubleValue)
@@ -62,7 +62,7 @@ class TestScalars(unittest.TestCase):
assert v.as_py() == 3.0
def test_string_unicode(self):
- arr = pa.from_pylist([u'foo', None, u'ma�ana'])
+ arr = pa.array([u'foo', None, u'ma�ana'])
v = arr[0]
assert isinstance(v, pa.StringValue)
@@ -75,7 +75,7 @@ class TestScalars(unittest.TestCase):
assert isinstance(v, unicode_type)
def test_bytes(self):
- arr = pa.from_pylist([b'foo', None, u('bar')])
+ arr = pa.array([b'foo', None, u('bar')])
v = arr[0]
assert isinstance(v, pa.BinaryValue)
@@ -89,7 +89,7 @@ class TestScalars(unittest.TestCase):
def test_fixed_size_bytes(self):
data = [b'foof', None, b'barb']
- arr = pa.from_pylist(data, type=pa.binary(4))
+ arr = pa.array(data, type=pa.binary(4))
v = arr[0]
assert isinstance(v, pa.FixedSizeBinaryValue)
@@ -102,7 +102,7 @@ class TestScalars(unittest.TestCase):
assert isinstance(v, bytes)
def test_list(self):
- arr = pa.from_pylist([['foo', None], None, ['bar'], []])
+ arr = pa.array([['foo', None], None, ['bar'], []])
v = arr[0]
assert len(v) == 2
http://git-wip-us.apache.org/repos/asf/arrow/blob/84d725ba/python/pyarrow/tests/test_table.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_table.py b/python/pyarrow/tests/test_table.py
index 79b4c15..0567e8a 100644
--- a/python/pyarrow/tests/test_table.py
+++ b/python/pyarrow/tests/test_table.py
@@ -29,7 +29,7 @@ class TestColumn(unittest.TestCase):
def test_basics(self):
data = [
- pa.from_pylist([-10, -5, 0, 5, 10])
+ pa.array([-10, -5, 0, 5, 10])
]
table = pa.Table.from_arrays(data, names=['a'])
column = table.column(0)
@@ -40,7 +40,7 @@ class TestColumn(unittest.TestCase):
assert column.to_pylist() == [-10, -5, 0, 5, 10]
def test_from_array(self):
- arr = pa.from_pylist([0, 1, 2, 3, 4])
+ arr = pa.array([0, 1, 2, 3, 4])
col1 = pa.Column.from_array('foo', arr)
col2 = pa.Column.from_array(pa.field('foo', arr.type), arr)
@@ -49,7 +49,7 @@ class TestColumn(unittest.TestCase):
def test_pandas(self):
data = [
- pa.from_pylist([-10, -5, 0, 5, 10])
+ pa.array([-10, -5, 0, 5, 10])
]
table = pa.Table.from_arrays(data, names=['a'])
column = table.column(0)
@@ -61,8 +61,8 @@ class TestColumn(unittest.TestCase):
def test_recordbatch_basics():
data = [
- pa.from_pylist(range(5)),
- pa.from_pylist([-10, -5, 0, 5, 10])
+ pa.array(range(5)),
+ pa.array([-10, -5, 0, 5, 10])
]
batch = pa.RecordBatch.from_arrays(data, ['c0', 'c1'])
@@ -78,8 +78,8 @@ def test_recordbatch_basics():
def test_recordbatch_slice():
data = [
- pa.from_pylist(range(5)),
- pa.from_pylist([-10, -5, 0, 5, 10])
+ pa.array(range(5)),
+ pa.array([-10, -5, 0, 5, 10])
]
names = ['c0', 'c1']
@@ -159,8 +159,8 @@ def test_recordbatchlist_schema_equals():
def test_table_basics():
data = [
- pa.from_pylist(range(5)),
- pa.from_pylist([-10, -5, 0, 5, 10])
+ pa.array(range(5)),
+ pa.array([-10, -5, 0, 5, 10])
]
table = pa.Table.from_arrays(data, names=('a', 'b'))
assert len(table) == 5
@@ -179,9 +179,9 @@ def test_table_basics():
def test_table_add_column():
data = [
- pa.from_pylist(range(5)),
- pa.from_pylist([-10, -5, 0, 5, 10]),
- pa.from_pylist(range(5, 10))
+ pa.array(range(5)),
+ pa.array([-10, -5, 0, 5, 10]),
+ pa.array(range(5, 10))
]
table = pa.Table.from_arrays(data, names=('a', 'b', 'c'))
@@ -202,9 +202,9 @@ def test_table_add_column():
def test_table_remove_column():
data = [
- pa.from_pylist(range(5)),
- pa.from_pylist([-10, -5, 0, 5, 10]),
- pa.from_pylist(range(5, 10))
+ pa.array(range(5)),
+ pa.array([-10, -5, 0, 5, 10]),
+ pa.array(range(5, 10))
]
table = pa.Table.from_arrays(data, names=('a', 'b', 'c'))
@@ -223,15 +223,15 @@ def test_concat_tables():
[1., 2., 3., 4., 5.]
]
- t1 = pa.Table.from_arrays([pa.from_pylist(x) for x in data],
+ t1 = pa.Table.from_arrays([pa.array(x) for x in data],
names=('a', 'b'))
- t2 = pa.Table.from_arrays([pa.from_pylist(x) for x in data2],
+ t2 = pa.Table.from_arrays([pa.array(x) for x in data2],
names=('a', 'b'))
result = pa.concat_tables([t1, t2])
assert len(result) == 10
- expected = pa.Table.from_arrays([pa.from_pylist(x + y)
+ expected = pa.Table.from_arrays([pa.array(x + y)
for x, y in zip(data, data2)],
names=('a', 'b'))
@@ -240,8 +240,8 @@ def test_concat_tables():
def test_table_pandas():
data = [
- pa.from_pylist(range(5)),
- pa.from_pylist([-10, -5, 0, 5, 10])
+ pa.array(range(5)),
+ pa.array([-10, -5, 0, 5, 10])
]
table = pa.Table.from_arrays(data, names=('a', 'b'))