def to_dict(self, columns=None):
        """
        Return a python dict from a pandas dataframe, with columns as keys
        :return: dict
        """
        if columns:
            assert len(columns) == len(self.feature_names)
        d = [
            dict([
                (columns[i] if columns else col_name, row[i])
                for i, col_name in enumerate(self.feature_names)
            ])
            for row in self.data
        ]
        return d
def to_dict ( self , columns = None ) : if columns : assert len ( columns ) == len ( self . feature_names ) d = [ dict ( [ ( columns [ i ] if columns else col_name , row [ i ] ) for i , col_name in enumerate ( self . feature_names ) ] ) for row in self . data ] return d
Return a python dict from a pandas dataframe, with columns as keys
        :return: dict