class_docstr: An Arrow Dataset for reading record batches from an input stream.
  Currently supported input streams are a socket client or stdin.
docstr: Create an ArrowStreamDataset by serving a DataFrame, or batches of a
  DataFrame in a background thread. This constructor requires pandas and
  pyarrow to be installed.
  
  Args:
      data_frames: A Pandas DataFrame or sequence of DataFrames
      columns: Optional column indices to use, if None all are used
      preserve_index: Flag to include the DataFrame index as the last column
      batch_size: Batch size of output tensors, setting a batch size here
                  will create batched tensors from Arrow memory and can be more
                  efficient than using tf.data.Dataset.batch().
                  NOTE: Currently, only 'keep_remainder' batch mode supported
docstr_tok: ["Create","an","ArrowStreamDataset","by","serving","a","DataFrame",",","or","batches","of","a","DataFrame","in","a","background","thread",".","This","constructor","requires","pandas","and","pyarrow","to","be","installed",".","Args",":","data_frames",":","A","Pandas","DataFrame","or","sequence","of","DataFrames","columns",":","Optional","column","indices","to","use",",","if","None","all","are","used","preserve_index",":","Flag","to","include","the","DataFrame","index","as","the","last","column","batch_size",":","Batch","size","of","output","tensors",",","setting","a","batch","size","here","will","create","batched","tensors","from","Arrow","memory","and","can","be","more","efficient","than","using","tf.data.Dataset.batch","(",")",".","NOTE",":","Currently",",","only","'keep_remainder","'","batch","mode","supported"]
code: def from_pandas(
      cls,
      data_frames,
      columns=None,
      preserve_index=True,
      batch_size=None,
  ):
      """Create an ArrowStreamDataset by serving a DataFrame, or batches of a
      DataFrame in a background thread. This constructor requires pandas and
      pyarrow to be installed.
  
      Args:
          data_frames: A Pandas DataFrame or sequence of DataFrames
          columns: Optional column indices to use, if None all are used
          preserve_index: Flag to include the DataFrame index as the last column
          batch_size: Batch size of output tensors, setting a batch size here
                      will create batched tensors from Arrow memory and can be more
                      efficient than using tf.data.Dataset.batch().
                      NOTE: Currently, only 'keep_remainder' batch mode supported
      """
      import pandas as pd  # pylint: disable=import-outside-toplevel
      import pyarrow as pa  # pylint: disable=import-outside-toplevel
  
      if isinstance(data_frames, pd.DataFrame):
          data_frames = [data_frames]
  
      def gen_record_batches():
          """record batch generator"""
          for df in data_frames:
              if columns is not None:
                  df = df.iloc[:, list(columns)]
  
              # If batching, slice DataFrame and convert to record batches
              if batch_size is not None:
                  # Pandas will produce a partial batch if there is a remainder
                  for i in range(0, len(df), batch_size):
                      df_slice = df[i : i + batch_size]
                      batch = pa.RecordBatch.from_pandas(
                          df_slice, preserve_index=preserve_index
                      )
                      yield batch
              # Not batching, convert entire DataFrame to one record batch
              else:
                  batch = pa.RecordBatch.from_pandas(
                      df, preserve_index=preserve_index
                  )
                  yield batch
  
      # Get first batch to convert schema to output types and shapes
      record_batch_iter = gen_record_batches()
      batch = next(record_batch_iter)
      output_types, output_shapes = arrow_schema_to_tensor_types(
          batch.schema
      )
  
      return cls.from_record_batches(
          chain([batch], record_batch_iter),
          output_types,
          output_shapes,
          batch_size=batch_size,
          batch_mode="keep_remainder",
          record_batch_iter_factory=gen_record_batches,
      )
  
imports: from functools import partial
  import io
  from itertools import chain
  import os
  import socket
  import threading
  import tempfile
  import tensorflow
  from tensorflow import dtypes
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.util import structure
  from tensorflow_io.python.ops import core_ops
label_desc: Use image node_id 4 for calling the ArrowStreamDataset obj's underlying member method code with example usage: obj.from_pandas(cls, data_frames, columns, preserve_index, batch_size) and returns: cls