(self)
| 1242 | assert table.to_pydict() == expected |
| 1243 | |
| 1244 | def test_custom_nulls(self): |
| 1245 | # Infer nulls with custom values |
| 1246 | opts = ConvertOptions(null_values=['Xxx', 'Zzz']) |
| 1247 | rows = b"""a,b,c,d\nZzz,"Xxx",1,2\nXxx,#N/A,,Zzz\n""" |
| 1248 | table = self.read_bytes(rows, convert_options=opts) |
| 1249 | schema = pa.schema([('a', pa.null()), |
| 1250 | ('b', pa.string()), |
| 1251 | ('c', pa.string()), |
| 1252 | ('d', pa.int64())]) |
| 1253 | assert table.schema == schema |
| 1254 | assert table.to_pydict() == { |
| 1255 | 'a': [None, None], |
| 1256 | 'b': ["Xxx", "#N/A"], |
| 1257 | 'c': ["1", ""], |
| 1258 | 'd': [2, None], |
| 1259 | } |
| 1260 | |
| 1261 | opts = ConvertOptions(null_values=['Xxx', 'Zzz'], |
| 1262 | strings_can_be_null=True) |
| 1263 | table = self.read_bytes(rows, convert_options=opts) |
| 1264 | assert table.to_pydict() == { |
| 1265 | 'a': [None, None], |
| 1266 | 'b': [None, "#N/A"], |
| 1267 | 'c': ["1", ""], |
| 1268 | 'd': [2, None], |
| 1269 | } |
| 1270 | opts.quoted_strings_can_be_null = False |
| 1271 | table = self.read_bytes(rows, convert_options=opts) |
| 1272 | assert table.to_pydict() == { |
| 1273 | 'a': [None, None], |
| 1274 | 'b': ["Xxx", "#N/A"], |
| 1275 | 'c': ["1", ""], |
| 1276 | 'd': [2, None], |
| 1277 | } |
| 1278 | |
| 1279 | opts = ConvertOptions(null_values=[]) |
| 1280 | rows = b"a,b\n#N/A,\n" |
| 1281 | table = self.read_bytes(rows, convert_options=opts) |
| 1282 | schema = pa.schema([('a', pa.string()), |
| 1283 | ('b', pa.string())]) |
| 1284 | assert table.schema == schema |
| 1285 | assert table.to_pydict() == { |
| 1286 | 'a': ["#N/A"], |
| 1287 | 'b': [""], |
| 1288 | } |
| 1289 | |
| 1290 | def test_custom_bools(self): |
| 1291 | # Infer booleans with custom values |
nothing calls this directly
no test coverage detected