src/datasets/table.py
def from_tables(cls, tables: List[Union[pa.Table, Table]], axis: int = 0) -> "ConcatenationTable":
        """Create ConcatenationTable from list of tables.

        Args:
            tables (list of :class:`Table` or list of :obj:`pyarrow.Table`): List of tables.
            axis: (``{0, 1}``, default ``0``, meaning over rows):
            Axis to concatenate over, where ``0`` means over rows (vertically) and ``1`` means over columns
            (horizontally).

            .. versionadded:: 1.6.0
        """

        def to_blocks(table):
            if isinstance(table, pa.Table):
                return [[InMemoryTable(table)]]
            elif isinstance(table, ConcatenationTable):
                return copy.deepcopy(table.blocks)
            else:
                return [[table]]

        def _split_like(blocks_to_split, blocks_like):
            splits = []
            offset = 0
            for block_row in blocks_like:
                length = block_row[0].num_rows
                splits.append((offset, length))
                offset += length
            return [
                [block.slice(offset=split[0], length=split[1]) for block in blocks_to_split[0]] for split in splits
            ]

        def _extend_blocks(result, blocks: List[List[TableBlock]], axis: int = 0):
            if axis == 0:
                result.extend(blocks)
            elif axis == 1:
                if len(result) == 1 and len(blocks) > 1:
                    result = _split_like(result, blocks)  # Split result
                elif len(blocks) == 1 and len(result) > 1:
                    blocks = _split_like(blocks, result)  # Split blocks
                # TODO: This assumes each block_row has the same num_rows
                for i, row_blocks in enumerate(blocks):
                    result[i].extend(row_blocks)
            return result

        blocks = to_blocks(tables[0])
        for table in tables[1:]:
            table_blocks = to_blocks(table)
            blocks = _extend_blocks(blocks, table_blocks, axis=axis)
        return cls.from_blocks(blocks)
Create ConcatenationTable from list of tables.

        Args:
            tables (list of :class:`Table` or list of :obj:`pyarrow.Table`): List of tables.
            axis: (``{0, 1}``, default ``0``, meaning over rows):
            Axis to concatenate over, where ``0`` means over rows (vertically) and ``1`` means over columns
            (horizontally).

            .. versionadded:: 1.6.0
        
Create ConcatenationTable from list of tables.


Create ConcatenationTable from list of tables .
def from_tables(cls, tables: List[Union[pa.Table, Table]], axis: int = 0) -> "ConcatenationTable":
        def to_blocks(table):
            if isinstance(table, pa.Table):
                return [[InMemoryTable(table)]]
            elif isinstance(table, ConcatenationTable):
                return copy.deepcopy(table.blocks)
            else:
                return [[table]]
        def _split_like(blocks_to_split, blocks_like):
            splits = []
            offset = 0
            for block_row in blocks_like:
                length = block_row[0].num_rows
                splits.append((offset, length))
                offset += length
            return [
                [block.slice(offset=split[0], length=split[1]) for block in blocks_to_split[0]] for split in splits
            ]
        def _extend_blocks(result, blocks: List[List[TableBlock]], axis: int = 0):
            if axis == 0:
                result.extend(blocks)
            elif axis == 1:
                if len(result) == 1 and len(blocks) > 1:
                    result = _split_like(result, blocks)  
                elif len(blocks) == 1 and len(result) > 1:
                    blocks = _split_like(blocks, result)  
                for i, row_blocks in enumerate(blocks):
                    result[i].extend(row_blocks)
            return result
        blocks = to_blocks(tables[0])
        for table in tables[1:]:
            table_blocks = to_blocks(table)
            blocks = _extend_blocks(blocks, table_blocks, axis=axis)
        return cls.from_blocks(blocks)
def from_tables ( cls , tables : List [ Union [ pa . Table , Table ] ] , axis : int = 0 ) -> "ConcatenationTable" : def to_blocks ( table ) : if isinstance ( table , pa . Table ) : return [ [ InMemoryTable ( table ) ] ] elif isinstance ( table , ConcatenationTable ) : return copy . deepcopy ( table . blocks ) else : return [ [ table ] ] def _split_like ( blocks_to_split , blocks_like ) : splits = [ ] offset = 0 for block_row in blocks_like : length = block_row [ 0 ] . num_rows splits . append ( ( offset , length ) ) offset += length return [ [ block . slice ( offset = split [ 0 ] , length = split [ 1 ] ) for block in blocks_to_split [ 0 ] ] for split in splits ] def _extend_blocks ( result , blocks : List [ List [ TableBlock ] ] , axis : int = 0 ) : if axis == 0 : result . extend ( blocks ) elif axis == 1 : if len ( result ) == 1 and len ( blocks ) > 1 : result = _split_like ( result , blocks ) elif len ( blocks ) == 1 and len ( result ) > 1 : blocks = _split_like ( blocks , result ) for i , row_blocks in enumerate ( blocks ) : result [ i ] . extend ( row_blocks ) return result blocks = to_blocks ( tables [ 0 ] ) for table in tables [ 1 : ] : table_blocks = to_blocks ( table ) blocks = _extend_blocks ( blocks , table_blocks , axis = axis ) return cls . from_blocks ( blocks )
Create ConcatenationTable from list of tables.
Create ConcatenationTable from list of tables .
"""Create ConcatenationTable from list of tables.

        Args:
            tables (list of :class:`Table` or list of :obj:`pyarrow.Table`): List of tables.
            axis: (``{0, 1}``, default ``0``, meaning over rows):
            Axis to concatenate over, where ``0`` means over rows (vertically) and ``1`` means over columns
            (horizontally).

            .. versionadded:: 1.6.0
        """ # Split result # Split blocks # TODO: This assumes each block_row has the same num_rows
cls
tables
List[Union[pa.Table, Table]]
axis
int