kharoc commented on a change in pull request #10854:
URL: https://github.com/apache/arrow/pull/10854#discussion_r681932100
##########
File path: python/pyarrow/table.pxi
##########
@@ -616,6 +616,53 @@ cdef class RecordBatch(_PandasConvertible):
self.sp_batch = batch
self.batch = batch.get()
+ @staticmethod
+ def from_pydict(mapping, schema=None, metadata=None):
+ """
+ Construct a RecordBatch from Arrow arrays or columns.
+
+ Parameters
+ ----------
+ mapping : dict or Mapping
+ A mapping of strings to Arrays or Python lists.
+ schema : Schema, default None
+ If not passed, will be inferred from the Mapping values.
+ metadata : dict or Mapping, default None
+ Optional metadata for the schema (if inferred).
+
+ Returns
+ -------
+ RecordBatch
+ """
+ arrays = []
+ if schema is None:
+ names = []
+ for k, v in mapping.items():
+ names.append(k)
+ arrays.append(asarray(v))
+ return RecordBatch.from_arrays(arrays, names, metadata=metadata)
+ elif isinstance(schema, Schema):
+ for field in schema:
+ try:
+ v = mapping[field.name]
+ except KeyError:
+ try:
+ v = mapping[tobytes(field.name)]
Review comment:
to bytes function was removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]