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

Method write_batches

python/pyarrow/tests/test_ipc.py:57–80  ·  view source on GitHub ↗
(self, num_batches=5, as_table=False)

Source from the content-addressed store, hash-verified

55 return self.sink.getvalue()
56
57 def write_batches(self, num_batches=5, as_table=False):
58 nrows = 5
59 schema = pa.schema([('one', pa.float64()), ('two', pa.utf8())])
60
61 writer = self._get_writer(self.sink, schema)
62
63 batches = []
64 for i in range(num_batches):
65 batch = pa.record_batch(
66 [[random.random() for _ in range(nrows)],
67 ['foo', None, 'bar', 'bazbaz', 'qux']],
68 schema=schema)
69 batches.append(batch)
70
71 if as_table:
72 table = pa.Table.from_batches(batches)
73 writer.write_table(table)
74 else:
75 for batch in batches:
76 writer.write_batch(batch)
77
78 self.write_stats = writer.stats
79 writer.close()
80 return batches
81
82
83class FileFormatFixture(IpcFixture):

Callers 15

_check_roundtripMethod · 0.80
test_file_read_allFunction · 0.80
test_file_read_pandasFunction · 0.80
test_file_pathlibFunction · 0.80
test_open_stream_optionsFunction · 0.80
test_open_file_optionsFunction · 0.80

Calls 6

write_batchMethod · 0.80
schemaMethod · 0.45
_get_writerMethod · 0.45
appendMethod · 0.45
write_tableMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected