Convert dimension values to DataFrame.

        Returns a pandas dataframe of columns along each dimension,
        either completely flat or indexed by key dimensions.

        Args:
            dimensions: Dimensions to return as columns
            multi_index: Convert key dimensions to (multi-)index

        Returns:
            DataFrame of columns corresponding to each dimension

def dframe(self, dimensions=None, multi_index=False):
        """Convert dimension values to DataFrame.

        Returns a pandas dataframe of columns along each dimension,
        either completely flat or indexed by key dimensions.

        Args:
            dimensions: Dimensions to return as columns
            multi_index: Convert key dimensions to (multi-)index

        Returns:
            DataFrame of columns corresponding to each dimension
        """
        import pandas as pd
        if dimensions is None:
            outer_dimensions = self.kdims
            inner_dimensions = None
        else:
            outer_dimensions = [self.get_dimension(d) for d in dimensions
                                if d in self.kdims]
            inner_dimensions = [d for d in dimensions
                                if d not in outer_dimensions]
        inds = [(d, self.get_dimension_index(d)) for d in outer_dimensions]

        dframes = []
        for key, element in self.data.items():
            df = element.dframe(inner_dimensions, multi_index)
            names = [d.name for d in outer_dimensions]
            key_dims = [(d.name, key[i]) for d, i in inds]
            if multi_index:
                length = len(df)
                indexes = [[v]*length for _, v in key_dims]
                if df.index.names != [None]:
                    indexes += [df.index]
                    names += list(df.index.names)
                df = df.set_index(indexes)
                df.index.names = names
            else:
                for dim, val in key_dims:
                    dimn = 1
                    while dim in df:
                        dim = dim+'_%d' % dimn
                        if dim in df:
                            dimn += 1
                    df.insert(0, dim, val)
            dframes.append(df)
        return pd.concat(dframes)