How to use the pyarrow.Table.from_arrays function in pyarrow

To help you get started, we’ve selected a few pyarrow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blue-yonder / turbodbc / python / turbodbc_test / test_executemanycolumns.py View on Github external
def test_multiple_columns(dsn, configuration, column_backend):
    with open_cursor(configuration) as cursor:
        with query_fixture(cursor, configuration, 'INSERT TWO INTEGER COLUMNS') as table_name:
            columns = [array([17, 23, 42], dtype='int64'), array([3, 2, 1], dtype='int64')]
            if column_backend == 'arrow':
                columns = [pa.Array.from_pandas(x) for x in columns]
                columns = pa.Table.from_arrays(columns, ['column1', 'column2'])
            cursor.executemanycolumns("INSERT INTO {} VALUES (?, ?)".format(table_name), columns)

            results = cursor.execute("SELECT A, B FROM {} ORDER BY A".format(table_name)).fetchall()
            assert results == [[17, 3], [23, 2], [42, 1]]
github omnisci / pymapd / tests / test_integration.py View on Github external
columns = [pa.array([True, False, None], type=pa.bool_()),
                   pa.array([1, 0, None]).cast(pa.int16()),
                   pa.array([1, 0, None]).cast(pa.int32()),
                   pa.array([1, 0, None]),
                   pa.array([1.0, 1.1, None]).cast(pa.float32()),
                   pa.array([1.0, 1.1, None]),
                   # no fixed-width string
                   pa.array(['a', 'b', None]),
                   pa.array(['a', 'b', None]),
                   (pa.array([1, 2, None]).cast(pa.int32())
                    .cast(pa.time32('s'))),
                   pa.array([datetime.datetime(2016, 1, 1, 12, 12, 12),
                             datetime.datetime(2017, 1, 1), None]),
                   pa.array([datetime.date(2016, 1, 1),
                             datetime.date(2017, 1, 1), None])]
        table = pa.Table.from_arrays(columns, names=names)
        con.load_table_arrow("all_types", table)
        c.execute('drop table if exists all_types;')
github bmoscon / cryptostore / cryptostore / data / parquet.py View on Github external
def aggregate(self, data):
        names = list(data[0].keys())
        cols = {name: [] for name in names}

        for entry in data:
            for key in entry:
                val = entry[key]
                cols[key].append(val)
        arrays = [pa.array(cols[col]) for col in cols]
        table = pa.Table.from_arrays(arrays, names=names)
        self.data = table
github googleapis / google-cloud-python / bigquery / google / cloud / bigquery / _pandas_helpers.py View on Github external
arrow_arrays = []
    arrow_names = []
    arrow_fields = []
    for bq_field in bq_schema:
        arrow_fields.append(bq_to_arrow_field(bq_field))
        arrow_names.append(bq_field.name)
        arrow_arrays.append(
            bq_to_arrow_array(get_column_or_index(dataframe, bq_field.name), bq_field)
        )

    if all((field is not None for field in arrow_fields)):
        return pyarrow.Table.from_arrays(
            arrow_arrays, schema=pyarrow.schema(arrow_fields)
        )
    return pyarrow.Table.from_arrays(arrow_arrays, names=arrow_names)
github graphistry / pygraphistry / graphistry / ext / neo4j.py View on Github external
def _node_table(
    nodes,
    node_id,
    neo4j_label
):
    attribute_names = _attributes_for_entities(nodes)
    return arrow.Table.from_arrays(
        [column for column in itertools.chain(
            _intrinsic_node_columns(
                nodes=nodes,
                node_id=node_id,
                neo4j_label=neo4j_label
            ),
            _columns_for_entity(
                entities=nodes,
                entity_attributes=attribute_names
            )
github smandaric / bigquerylayers / libs / google / cloud / bigquery / table.py View on Github external
def to_arrow(self, progress_bar_type=None):
        """[Beta] Create an empty class:`pyarrow.Table`.

        Args:
            progress_bar_type (Optional[str]):
                Ignored. Added for compatibility with RowIterator.

        Returns:
            pyarrow.Table:
                An empty :class:`pyarrow.Table`.
        """
        if pyarrow is None:
            raise ValueError(_NO_PYARROW_ERROR)
        return pyarrow.Table.from_arrays(())
github googleapis / google-cloud-python / bigquery / google / cloud / bigquery / table.py View on Github external
bqstorage_client=None,
        create_bqstorage_client=False,
    ):
        """[Beta] Create an empty class:`pyarrow.Table`.

        Args:
            progress_bar_type (Optional[str]): Ignored. Added for compatibility with RowIterator.
            bqstorage_client (Any): Ignored. Added for compatibility with RowIterator.
            create_bqstorage_client (bool): Ignored. Added for compatibility with RowIterator.

        Returns:
            pyarrow.Table: An empty :class:`pyarrow.Table`.
        """
        if pyarrow is None:
            raise ValueError(_NO_PYARROW_ERROR)
        return pyarrow.Table.from_arrays(())
github vaexio / vaex / packages / vaex-arrow / vaex_arrow / convert.py View on Github external
def arrow_table_from_vaex_df(ds, column_names=None, selection=None, strings=True, virtual=False):
    """Implementation of Dataset.to_arrow_table"""
    names = []
    arrays = []
    for name, array in ds.to_items(column_names=column_names, selection=selection, strings=strings, virtual=virtual):
        names.append(name)
        arrays.append(arrow_array_from_numpy_array(array))
    return pyarrow.Table.from_arrays(arrays, names)
github googleapis / google-cloud-python / bigquery / google / cloud / bigquery / _pandas_helpers.py View on Github external
raise ValueError(
            u"bq_schema is missing fields from dataframe: {}".format(missing_fields)
        )

    arrow_arrays = []
    arrow_names = []
    arrow_fields = []
    for bq_field in bq_schema:
        arrow_fields.append(bq_to_arrow_field(bq_field))
        arrow_names.append(bq_field.name)
        arrow_arrays.append(
            bq_to_arrow_array(get_column_or_index(dataframe, bq_field.name), bq_field)
        )

    if all((field is not None for field in arrow_fields)):
        return pyarrow.Table.from_arrays(
            arrow_arrays, schema=pyarrow.schema(arrow_fields)
        )
    return pyarrow.Table.from_arrays(arrow_arrays, names=arrow_names)