code: def df(objs, labels=None):
      
      import pandas as pd
      from .objects import Object, DynamicObject
      if objs:
          objs = list(objs)
          obj = objs[0]
          if isinstance(obj, Object):
              df = pd.DataFrame.from_records(o.tuple() for o in objs)
              df.columns = obj.__class__.defaults
          elif isinstance(obj, DynamicObject):
              df = pd.DataFrame.from_records(o.__dict__ for o in objs)
          else:
              df = pd.DataFrame.from_records(objs)
          if isinstance(obj, tuple) and hasattr(obj, '_fields'):
              # assume it's a namedtuple
              df.columns = obj.__class__._fields
      else:
          df = None
      if labels:
          exclude = [label for label in df if label not in labels]
          df = df.drop(exclude, axis=1)
      return df
docs: Create pandas DataFrame from the sequence of same-type objects.
      When a list of labels is given then only retain those labels and
      drop the rest.