def get_dataframe(self, output_columns=None):
        """Get a Pandas DataFrame of the datapoints in this instance.

        Arguments:
            output_columns (`list`, optional): List of strings specifying the columns to include
                in the output DataFrame. The default is `None`, which outputs all of the
                columns. Options include (not case sensitive):

                    * ``Temperature``
                    * ``Pressure``
                    * ``Ignition Delay``
                    * ``Composition``
                    * ``Equivalence Ratio``
                    * ``Reference``
                    * ``Apparatus``
                    * ``Experiment Type``
                    * ``File Author``
                    * ``File Version``
                    * ``ChemKED Version``

                In addition, specific fields from the ``Reference`` and ``Apparatus`` attributes can
                be included by specifying the name after a colon. These options are:

                    * ``Reference:Volume``
                    * ``Reference:Journal``
                    * ``Reference:DOI``
                    * ``Reference:Authors``
                    * ``Reference:Detail``
                    * ``Reference:Year``
                    * ``Reference:Pages``
                    * ``Apparatus:Kind``
                    * ``Apparatus:Facility``
                    * ``Apparatus:Institution``

                Only the first author is printed when ``Reference`` or ``Reference:Authors`` is
                selected because the whole author list may be quite long.

        Note:
            If the Composition is selected as an output type, the composition specified in the
            `DataPoint` is used. No attempt is made to convert to a consistent basis; mole fractions
            will remain mole fractions, mass fractions will remain mass fractions, and mole percent
            will remain mole percent. Therefore, it is possible to end up with more than one type of
            composition specification in a given column. However, if the composition is included
            in the resulting dataframe, the type of each composition will be specified by the "Kind"
            field in each row.

        Examples:
            >>> df = ChemKED(yaml_file).get_dataframe()
            >>> df = ChemKED(yaml_file).get_dataframe(['Temperature', 'Ignition Delay'])

        Returns:
            `~pandas.DataFrame`: Contains the information regarding each point in the ``datapoints``
                attribute
        """
        import pandas as pd

        valid_labels = [a.replace('_', ' ') for a in self.__dict__
                        if not (a.startswith('__') or a.startswith('_'))
                        ]
        valid_labels.remove('datapoints')
        valid_labels.extend(
            ['composition', 'ignition delay', 'temperature', 'pressure', 'equivalence ratio']
        )
        ref_index = valid_labels.index('reference')
        valid_labels[ref_index:ref_index + 1] = ['reference:' + a for a in Reference._fields]
        app_index = valid_labels.index('apparatus')
        valid_labels[app_index:app_index + 1] = ['apparatus:' + a for a in Apparatus._fields]
        species_list = list(set(chain(*[list(d.composition.keys()) for d in self.datapoints])))

        if output_columns is None or len(output_columns) == 0:
            col_labels = valid_labels
            comp_index = col_labels.index('composition')
            col_labels[comp_index:comp_index + 1] = species_list + ['Composition:Kind']
        else:
            output_columns = [a.lower() for a in output_columns]
            col_labels = []
            for col in output_columns:
                if col in valid_labels or col in ['reference', 'apparatus']:
                    col_labels.append(col)
                else:
                    raise ValueError('{} is not a valid output column choice'.format(col))

            if 'composition' in col_labels:
                comp_index = col_labels.index('composition')
                col_labels[comp_index:comp_index + 1] = species_list + ['Composition:Kind']
            if 'reference' in col_labels:
                ref_index = col_labels.index('reference')
                col_labels[ref_index:ref_index + 1] = ['reference:' + a for a in Reference._fields]
            if 'apparatus' in col_labels:
                app_index = col_labels.index('apparatus')
                col_labels[app_index:app_index + 1] = ['apparatus:' + a for a in Apparatus._fields]

        data = []
        for d in self.datapoints:
            row = []
            d_species = list(d.composition.keys())
            for col in col_labels:
                if col in species_list:
                    if col in d_species:
                        row.append(d.composition[col].amount)
                    else:
                        row.append(Q_(0.0, 'dimensionless'))
                elif 'reference' in col or 'apparatus' in col:
                    split_col = col.split(':')
                    if split_col[1] == 'authors':
                        row.append(getattr(getattr(self, split_col[0]), split_col[1])[0]['name'])
                    else:
                        row.append(getattr(getattr(self, split_col[0]), split_col[1]))
                elif col in ['temperature', 'pressure', 'ignition delay', 'equivalence ratio']:
                    row.append(getattr(d, col.replace(' ', '_')))
                elif col == 'file authors':
                    row.append(getattr(self, col.replace(' ', '_'))[0]['name'])
                elif col == 'Composition:Kind':
                    row.append(d.composition_type)
                else:
                    row.append(getattr(self, col.replace(' ', '_')))
            data.append(row)

        col_labels = [a.title() for a in col_labels]
        columns = pd.Index(col_labels)
        return pd.DataFrame(data=data, columns=columns)
def get_dataframe ( self , output_columns = None ) : import pandas as pd valid_labels = [ a . replace ( '_' , ' ' ) for a in self . __dict__ if not ( a . startswith ( '__' ) or a . startswith ( '_' ) ) ] valid_labels . remove ( 'datapoints' ) valid_labels . extend ( [ 'composition' , 'ignition delay' , 'temperature' , 'pressure' , 'equivalence ratio' ] ) ref_index = valid_labels . index ( 'reference' ) valid_labels [ ref_index : ref_index + 1 ] = [ 'reference:' + a for a in Reference . _fields ] app_index = valid_labels . index ( 'apparatus' ) valid_labels [ app_index : app_index + 1 ] = [ 'apparatus:' + a for a in Apparatus . _fields ] species_list = list ( set ( chain ( * [ list ( d . composition . keys ( ) ) for d in self . datapoints ] ) ) ) if output_columns is None or len ( output_columns ) == 0 : col_labels = valid_labels comp_index = col_labels . index ( 'composition' ) col_labels [ comp_index : comp_index + 1 ] = species_list + [ 'Composition:Kind' ] else : output_columns = [ a . lower ( ) for a in output_columns ] col_labels = [ ] for col in output_columns : if col in valid_labels or col in [ 'reference' , 'apparatus' ] : col_labels . append ( col ) else : raise ValueError ( '{} is not a valid output column choice' . format ( col ) ) if 'composition' in col_labels : comp_index = col_labels . index ( 'composition' ) col_labels [ comp_index : comp_index + 1 ] = species_list + [ 'Composition:Kind' ] if 'reference' in col_labels : ref_index = col_labels . index ( 'reference' ) col_labels [ ref_index : ref_index + 1 ] = [ 'reference:' + a for a in Reference . _fields ] if 'apparatus' in col_labels : app_index = col_labels . index ( 'apparatus' ) col_labels [ app_index : app_index + 1 ] = [ 'apparatus:' + a for a in Apparatus . _fields ] data = [ ] for d in self . datapoints : row = [ ] d_species = list ( d . composition . keys ( ) ) for col in col_labels : if col in species_list : if col in d_species : row . append ( d . composition [ col ] . amount ) else : row . append ( Q_ ( 0.0 , 'dimensionless' ) ) elif 'reference' in col or 'apparatus' in col : split_col = col . split ( ':' ) if split_col [ 1 ] == 'authors' : row . append ( getattr ( getattr ( self , split_col [ 0 ] ) , split_col [ 1 ] ) [ 0 ] [ 'name' ] ) else : row . append ( getattr ( getattr ( self , split_col [ 0 ] ) , split_col [ 1 ] ) ) elif col in [ 'temperature' , 'pressure' , 'ignition delay' , 'equivalence ratio' ] : row . append ( getattr ( d , col . replace ( ' ' , '_' ) ) ) elif col == 'file authors' : row . append ( getattr ( self , col . replace ( ' ' , '_' ) ) [ 0 ] [ 'name' ] ) elif col == 'Composition:Kind' : row . append ( d . composition_type ) else : row . append ( getattr ( self , col . replace ( ' ' , '_' ) ) ) data . append ( row ) col_labels = [ a . title ( ) for a in col_labels ] columns = pd . Index ( col_labels ) return pd . DataFrame ( data = data , columns = columns )
Get a Pandas DataFrame of the datapoints in this instance.

        Arguments:
            output_columns (`list`, optional): List of strings specifying the columns to include
                in the output DataFrame. The default is `None`, which outputs all of the
                columns. Options include (not case sensitive):

                    * ``Temperature``
                    * ``Pressure``
                    * ``Ignition Delay``
                    * ``Composition``
                    * ``Equivalence Ratio``
                    * ``Reference``
                    * ``Apparatus``
                    * ``Experiment Type``
                    * ``File Author``
                    * ``File Version``
                    * ``ChemKED Version``

                In addition, specific fields from the ``Reference`` and ``Apparatus`` attributes can
                be included by specifying the name after a colon. These options are:

                    * ``Reference:Volume``
                    * ``Reference:Journal``
                    * ``Reference:DOI``
                    * ``Reference:Authors``
                    * ``Reference:Detail``
                    * ``Reference:Year``
                    * ``Reference:Pages``
                    * ``Apparatus:Kind``
                    * ``Apparatus:Facility``
                    * ``Apparatus:Institution``

                Only the first author is printed when ``Reference`` or ``Reference:Authors`` is
                selected because the whole author list may be quite long.

        Note:
            If the Composition is selected as an output type, the composition specified in the
            `DataPoint` is used. No attempt is made to convert to a consistent basis; mole fractions
            will remain mole fractions, mass fractions will remain mass fractions, and mole percent
            will remain mole percent. Therefore, it is possible to end up with more than one type of
            composition specification in a given column. However, if the composition is included
            in the resulting dataframe, the type of each composition will be specified by the "Kind"
            field in each row.

        Examples:
            >>> df = ChemKED(yaml_file).get_dataframe()
            >>> df = ChemKED(yaml_file).get_dataframe(['Temperature', 'Ignition Delay'])

        Returns:
            `~pandas.DataFrame`: Contains the information regarding each point in the ``datapoints``
                attribute