class_docstr: ArrowDatasetTest
class_docstr_tok: ["ArrowDatasetTest"]
docstr: test_from_pandas_preserve_index
code: def test_from_pandas_preserve_index(self):
      """test_from_pandas_preserve_index"""
      import tensorflow_io.arrow as arrow_io
  
      data_v = [
          [1.0, 2.0, 3.0],
          [0.2, 0.4, 0.8],
      ]
  
      truth_data = TruthData(
          data_v,
          (tf.dtypes.float32, tf.dtypes.float32),
          (tf.TensorShape([]), tf.TensorShape([])),
      )
  
      batch = self.make_record_batch(truth_data)
      df = batch.to_pandas()
      dataset = arrow_io.ArrowDataset.from_pandas(
          df, preserve_index=True
      )
  
      # Add index column to test data to check results
      truth_data_with_index = TruthData(
          truth_data.data + [range(len(truth_data.data[0]))],
          truth_data.output_types + (tf.dtypes.int64,),
          truth_data.output_shapes + (tf.TensorShape([]),),
      )
      self.run_test_case(dataset, truth_data_with_index)
  
      # Test preserve_index again, selecting second column only
      # NOTE: need to select TruthData because `df` gets selected also
      truth_data_selected_with_index = TruthData(
          truth_data_with_index.data[1:],
          truth_data_with_index.output_types[1:],
          truth_data_with_index.output_shapes[1:],
      )
      dataset = arrow_io.ArrowDataset.from_pandas(
          df, columns=(1,), preserve_index=True
      )
      self.run_test_case(dataset, truth_data_selected_with_index)
  
imports: from collections import namedtuple
  import io
  import os
  import socket
  import tempfile
  import threading
  import pytest
  import pyarrow
  import numpy.testing
  import tensorflow
  import tensorflow_io
label_desc: Use image node_id 5 for calling the ArrowDatasetTest obj's underlying member method code with example usage: obj.test_from_pandas_preserve_index() without return types