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

Function test_pandas_roundtrip

python/pyarrow/tests/interchange/test_conversion.py:123–146  ·  view source on GitHub ↗
(uint, int, float, np_float_str)

Source from the content-addressed store, hash-verified

121 ]
122)
123def test_pandas_roundtrip(uint, int, float, np_float_str):
124 arr = [1, 2, 3]
125 table = pa.table(
126 {
127 "a": pa.array(arr, type=uint),
128 "b": pa.array(arr, type=int),
129 "c": pa.array(np.array(arr, dtype=np.dtype(np_float_str)), type=float),
130 "d": [True, False, True],
131 }
132 )
133 from pandas.api.interchange import (
134 from_dataframe as pandas_from_dataframe
135 )
136 pandas_df = pandas_from_dataframe(table)
137 result = pi.from_dataframe(pandas_df)
138 assert table.equals(result)
139
140 table_protocol = table.__dataframe__()
141 result_protocol = result.__dataframe__()
142
143 assert table_protocol.num_columns() == result_protocol.num_columns()
144 assert table_protocol.num_rows() == result_protocol.num_rows()
145 assert table_protocol.num_chunks() == result_protocol.num_chunks()
146 assert table_protocol.column_names() == result_protocol.column_names()
147
148
149@pytest.mark.pandas

Callers

nothing calls this directly

Calls 8

dtypeMethod · 0.80
equalsMethod · 0.80
__dataframe__Method · 0.80
arrayMethod · 0.45
num_columnsMethod · 0.45
num_rowsMethod · 0.45
num_chunksMethod · 0.45
column_namesMethod · 0.45

Tested by

no test coverage detected