Yield rows as lists of data.

        The data is exactly as it is in the source pandas DataFrames and
        any formulas are not resolved.
517107
def iterrows(self, workbook=None):
        
        resolved_tables = []
        max_height = 0
        max_width = 0

        # while yielding rows __formula_values is updated with any formula values set on Expressions
        self.__formula_values = {}

        for name, (table, (row, col)) in list(self.__tables.items()):
            # get the resolved 2d data array from the table
            #
            # expressions with no explicit table will use None when calling
            # get_table/get_table_pos, which should return the current table.
            #
            self.__tables[None] = (table, (row, col))
            data = table.get_data(workbook, row, col, self.__formula_values)
            del self.__tables[None]

            height, width = data.shape
            upper_left = (row, col)
            lower_right = (row + height - 1, col + width - 1)

            max_height = max(max_height, lower_right[0] + 1)
            max_width = max(max_width, lower_right[1] + 1)
            
            resolved_tables.append((name, data, upper_left, lower_right))

        for row, col in self.__values.keys():
            max_width = max(max_width, row+1)
            max_height = max(max_height, col+1)

        # Build the whole table up-front. Doing it row by row is too slow.
        table = [[None] * max_width for i in range(max_height)]
        for name, data, upper_left, lower_right in resolved_tables:
            for i, r in enumerate(range(upper_left[0], lower_right[0]+1)):
                for j, c in enumerate(range(upper_left[1], lower_right[1]+1)):
                    table[r][c] = data[i][j]

        for (r, c), value in self.__values.items():
            if isinstance(value, Value):
                value = value.value
            if isinstance(value, Expression):
                if value.has_value:
                    self.__formula_values[(r, c)] = value.value
                value = value.get_formula(workbook, r, c)
            table[r][c] = value

        for row in table:
            yield row
667989
def rows(self):
        
        rows = []
        for rowName in self.rowNames:
            row = {columnName: self[rowName, columnName] for columnName in self.columnNames}
            row["_"] = rowName
            rows.append(row)
        return rows
101913
def get_rows(self, sort=False):
        
        ret = []
        for _, rows in sorted(self._rows.items()) if sort else self._rows.items():
            self._rows_int2date(rows)
            ret.extend(rows)

        return ret
473532
def raw_row_generator(self):
        """"""
        from rowgenerators import get_generator

        self.doc.set_sys_path()  # Set sys path to package 'lib' dir in case of python function generator

        ru = self.resolved_url

        try:
            resource = ru.resource # For Metapack urls

            return resource.row_generator
        except AttributeError:
            pass

        ut = ru.get_resource().get_target()

        # Encoding is supposed to be preserved in the URL but isn't
        source_url = parse_app_url(self.url)

        # source_url will be None for Sql terms.

        ut.encoding = self.get_value('encoding') or (source_url.encoding if source_url else None)

        g = get_generator(ut,  resource=self,
                          doc=self._doc, working_dir=self._doc.doc_dir,
                          env=self.env)

        assert g, ut

        return g
64695
def values(self, **kwargs):
        """"""
        result = yield self.get(**kwargs)

        if not result['rows']:
            raise Return([])

        raise Return([x['value'] for x in result['rows']])
712818
def _to_dataframe_tabledata_list(self, dtypes, progress_bar=None):
        """"""
        column_names = [field.name for field in self.schema]
        frames = []

        for page in iter(self.pages):
            current_frame = self._to_dataframe_dtypes(page, column_names, dtypes)
            frames.append(current_frame)

            if progress_bar is not None:
                # In some cases, the number of total rows is not populated
                # until the first page of rows is fetched. Update the
                # progress bar's total to keep an accurate count.
                progress_bar.total = progress_bar.total or self.total_rows
                progress_bar.update(len(current_frame))

        if progress_bar is not None:
            # Indicate that the download has finished.
            progress_bar.close()

        return pandas.concat(frames)
869896
def write(self, rows, keyed=False):
        
        for row in rows:
            keyed_row = row
            if not keyed:
                keyed_row = dict(zip(self.__schema.field_names, row))
            keyed_row = self.__convert_row(keyed_row)
            if self.__check_existing(keyed_row):
                for wr in self.__insert():
                    yield wr
                ret = self.__update(keyed_row)
                if ret is not None:
                    yield WrittenRow(keyed_row, True, ret if self.__autoincrement else None)
                    continue
            self.__buffer.append(keyed_row)
            if len(self.__buffer) > BUFFER_SIZE:
                for wr in self.__insert():
                    yield wr
        for wr in self.__insert():
            yield wr
748677
function(data){
			var rows = this.calculateRowsNumber();
			var datas = [];
			for(var i = 0; i < data.length; i += rows){
				datas.push(data.slice(i, i+rows));
			}
			return datas;
		}
886057
def rows_to_dicts(self, serialize_cell=None):
    """"""
    if serialize_cell is None:
      serialize_cell = self.get_cell_value
    # keys = [serialize_cell(cell) for cell in self.rows[0]]
    keys = self.headers(serialize_cell)
    for row in self.rows[1:]:
      yield dict(zip(keys, [serialize_cell(cell) for cell in row]))
214538
def _format_list(self, data):
        
        dataset = "["
        i = 0
        for el in data:
            if pd.isnull(el):
                dataset += "null"
            else:
                dtype = type(data[i])
                if dtype == int or dtype == float:
                    dataset += str(el)
                else:
                    dataset += '"' + el + '"'
            if i < len(data) - 1:
                dataset += ', '
        dataset += "]"
        return dataset
85378
def get_dataframes():
    """"""

    for k, v in caller_locals().items():
        if k.startswith('_'):
            continue

        if isinstance(v, pd.core.frame.DataFrame):
            yield k, v
483497
async def fetchall(self):
        
        rows = []
        while True:
            row = await self.fetchone()
            if row is None:
                break
            rows.append(row)
        return rows
1279279
def dfs(self):
        
        for node in self.children:
            for v in node.dfs:
                yield v
        yield self
670682
def prepare(self, data):
        
        result = []

        for item in self.get_inner_data(data):
            result.append(self.preparer.prepare(item))

        return result
790757
def rows(self):
        

        # Translate the term value name so it can be assigned to a parameter.
        tvm = self.section.doc.decl_terms.get(self.qualified_term, {}).get('termvaluename', '@value')
        assert tvm
        # Terminal children have no arguments, just a value. Here we put the terminal children
        # in a property array, so they can be written to the parent's arg-children columns
        # if the section has any.

        properties = {tvm: self.value}

        for c in self.children:
            if c.is_terminal:
                if c.record_term_lc:
                    # This is rare, but can happen if a property child is not given
                    # a property name by the section -- the "Section" term has a blank column.
                    properties[c.record_term_lc] = c.value

        yield (self.qualified_term, properties)

        # The non-terminal children have to get yielded normally -- they can't be arg-children
        for c in self.children:
            if not c.is_terminal:
                for row in c.rows:
                    yield row
1334690
def dataframe(self,asql, logger = None):
        """"""
        import pandas as pd
        from ambry.mprlib.exceptions import BadSQLError

        try:
            def yielder(cursor):

                for i, row in enumerate(cursor):
                    if i == 0:
                        yield [ e[0] for e in cursor.getdescription()]

                    yield row

            cursor = self.query(asql, logger)

            yld = yielder(cursor)

            header = next(yld)

            return pd.DataFrame(yld, columns=header)
        except BadSQLError as e:
            import traceback
            self._logger.error("SQL Error: {}".format( e))
            self._logger.debug(traceback.format_exc())
81478
def rows(self, table, cols):
        '''
        
        '''
        if self.orng_tables:
            data = []
            for ex in self.orng_tables[table]:
                data.append([ex[str(col)] for col in cols])
            return data
        else:
            return self.fetch(table, cols)