MCPcopy Create free account
hub / github.com/apache/arrow / test_get_columns

Function test_get_columns

python/pyarrow/tests/interchange/test_interchange_spec.py:216–237  ·  view source on GitHub ↗
(uint, int, float, np_float_str, use_batch)

Source from the content-addressed store, hash-verified

214)
215@pytest.mark.parametrize("use_batch", [False, True])
216def test_get_columns(uint, int, float, np_float_str, use_batch):
217 arr = [[1, 2, 3], [4, 5]]
218 arr_float = np.array([1, 2, 3, 4, 5], dtype=np.dtype(np_float_str))
219 table = pa.table(
220 {
221 "a": pa.chunked_array(arr, type=uint),
222 "b": pa.chunked_array(arr, type=int),
223 "c": pa.array(arr_float, type=float)
224 }
225 )
226 if use_batch:
227 table = table.combine_chunks().to_batches()[0]
228 df = table.__dataframe__()
229 for col in df.get_columns():
230 assert col.size() == 5
231 assert col.num_chunks() == 1
232
233 # 0 = DtypeKind.INT, 1 = DtypeKind.UINT, 2 = DtypeKind.FLOAT,
234 # see DtypeKind class in column.py
235 assert df.get_column(0).dtype[0] == 1 # UINT
236 assert df.get_column(1).dtype[0] == 0 # INT
237 assert df.get_column(2).dtype[0] == 2 # FLOAT
238
239
240@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 9

dtypeMethod · 0.80
chunked_arrayMethod · 0.80
to_batchesMethod · 0.80
__dataframe__Method · 0.80
get_columnsMethod · 0.80
get_columnMethod · 0.80
arrayMethod · 0.45
sizeMethod · 0.45
num_chunksMethod · 0.45

Tested by

no test coverage detected