parameters: (
          cls, data_frames, columns=None, preserve_index=True, batch_size=None
      )
return_statement: 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,
          )
docstring: 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
docstring_summary: 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.
docstring_tokens: 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 .
function: 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,
          )
function_tokens: def from_pandas ( cls , data_frames , columns = None , preserve_index = True , batch_size = None ) : 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 , )