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

Method test_custom_bools

python/pyarrow/tests/test_csv.py:1290–1309  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1288 }
1289
1290 def test_custom_bools(self):
1291 # Infer booleans with custom values
1292 opts = ConvertOptions(true_values=['T', 'yes'],
1293 false_values=['F', 'no'])
1294 rows = (b"a,b,c\n"
1295 b"True,T,t\n"
1296 b"False,F,f\n"
1297 b"True,yes,yes\n"
1298 b"False,no,no\n"
1299 b"N/A,N/A,N/A\n")
1300 table = self.read_bytes(rows, convert_options=opts)
1301 schema = pa.schema([('a', pa.string()),
1302 ('b', pa.bool_()),
1303 ('c', pa.string())])
1304 assert table.schema == schema
1305 assert table.to_pydict() == {
1306 'a': ["True", "False", "True", "False", "N/A"],
1307 'b': [True, False, True, False, None],
1308 'c': ["t", "f", "yes", "no", "N/A"],
1309 }
1310
1311 def test_column_types(self):
1312 # Ask for specific column types in ConvertOptions

Callers

nothing calls this directly

Calls 4

read_bytesMethod · 0.95
ConvertOptionsClass · 0.90
schemaMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected