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

Function test_table_integer_object_nulls_option

python/pyarrow/tests/test_pandas.py:1089–1108  ·  view source on GitHub ↗
(dtype)

Source from the content-addressed store, hash-verified

1087@pytest.mark.parametrize('dtype',
1088 ['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8'])
1089def test_table_integer_object_nulls_option(dtype):
1090 num_values = 100
1091
1092 null_mask = np.random.randint(0, 10, size=num_values) < 3
1093 values = np.random.randint(0, 100, size=num_values, dtype=dtype)
1094
1095 array = pa.array(values, mask=null_mask)
1096
1097 if null_mask.any():
1098 expected = values.astype('O')
1099 expected[null_mask] = None
1100 else:
1101 expected = values
1102
1103 expected = pd.DataFrame({dtype: expected})
1104
1105 table = pa.Table.from_arrays([array], [dtype])
1106 result = table.to_pandas(integer_object_nulls=True)
1107
1108 tm.assert_frame_equal(result, expected)
1109
1110
1111class TestConvertDateTimeLikeTypes:

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.45

Tested by

no test coverage detected