code: def to_pandas_dataframe(self, sample_column=False):
          
          import pandas as pd
  
          if sample_column:
              df = pd.DataFrame(self.data(sorted_by=None, sample_dict_cast=True))
  
          else:
              # work directly with the record, it's much faster
              df = pd.DataFrame(self.record.sample, columns=self.variables)
  
              for field in sorted(self.record.dtype.fields):  # sort for consistency
                  if field == 'sample':
                      continue
  
                  df.loc[:, field] = self.record[field]
  
          return df
docs: Convert a SampleSet to a Pandas DataFrame
  
          Returns:
              :obj:`pandas.DataFrame`
  
          Examples:
              >>> samples = dimod.SampleSet.from_samples([{'a': -1, 'b': +1, 'c': -1},
              ...                                         {'a': -1, 'b': -1, 'c': +1}],
              ...                                        dimod.SPIN, energy=-.5)
              >>> samples.to_pandas_dataframe()  # doctest: +SKIP
                 a  b  c  energy  num_occurrences
              0 -1  1 -1    -0.5                1
              1 -1 -1  1    -0.5                1
              >>> samples.to_pandas_dataframe(sample_column=True)  # doctest: +SKIP
                                     sample  energy  num_occurrences
              0  {'a': -1, 'b': 1, 'c': -1}    -0.5                1
              1  {'a': -1, 'b': -1, 'c': 1}    -0.5                1