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

Function test_dataframe

python/pyarrow/tests/interchange/test_interchange_spec.py:156–174  ·  view source on GitHub ↗
(use_batch)

Source from the content-addressed store, hash-verified

154
155@pytest.mark.parametrize("use_batch", [False, True])
156def test_dataframe(use_batch):
157 n = pa.chunked_array([[2, 2, 4], [4, 5, 100]])
158 a = pa.chunked_array([["Flamingo", "Parrot", "Cow"],
159 ["Horse", "Brittle stars", "Centipede"]])
160 table = pa.table([n, a], names=['n_legs', 'animals'])
161 if use_batch:
162 table = table.combine_chunks().to_batches()[0]
163 df = table.__dataframe__()
164
165 assert df.num_columns() == 2
166 assert df.num_rows() == 6
167 if use_batch:
168 assert df.num_chunks() == 1
169 else:
170 assert df.num_chunks() == 2
171 assert list(df.column_names()) == ['n_legs', 'animals']
172 assert list(df.select_columns((1,)).column_names()) == list(
173 df.select_columns_by_name(("animals",)).column_names()
174 )
175
176
177@pytest.mark.parametrize("use_batch", [False, True])

Callers

nothing calls this directly

Calls 10

listFunction · 0.85
chunked_arrayMethod · 0.80
to_batchesMethod · 0.80
__dataframe__Method · 0.80
num_columnsMethod · 0.45
num_rowsMethod · 0.45
num_chunksMethod · 0.45
column_namesMethod · 0.45
select_columnsMethod · 0.45

Tested by

no test coverage detected