Table Classes
Each Dataset
object is backed by a PyArrow Table.
A Table can be loaded from either the disk (memory mapped) or in memory.
Several Table types are available, and they all inherit from table.Table.
Table
Wraps a pyarrow Table by using composition.
This is the base class for InMemoryTable
, MemoryMappedTable
and ConcatenationTable
.
It implements all the basic attributes/methods of the pyarrow Table class except
the Table transforms: slice, filter, flatten, combine_chunks, cast, add_column, append_column, remove_column, set_column, rename_columns
and drop
.
The implementation of these methods differs for the subclasses.
validate
< source >( *args **kwargs )
Perform validation checks. An exception is raised if validation fails.
By default only cheap validation checks are run. Pass full=True
for thorough validation checks (potentially O(n)
).
equals
< source >(
*args
**kwargs
)
→
bool
Parameters
- other (Table) — Table to compare against.
-
check_metadata
bool
, defaults toFalse
) — Whether schema metadata equality should be checked as well.
Returns
bool
Check if contents of two tables are equal.
to_batches
< source >( *args **kwargs )
Convert Table to list of (contiguous) RecordBatch
objects.
Convert the Table to a dict
or OrderedDict
.
to_pandas
< source >(
*args
**kwargs
)
→
pandas.Series
or pandas.DataFrame
Parameters
-
memory_pool (
MemoryPool
, defaults toNone
) — Arrow MemoryPool to use for allocations. Uses the default memory pool is not passed. -
strings_to_categorical (
bool
, defaults toFalse
) — Encode string (UTF8) and binary types topandas.Categorical
. -
categories (
list
, defaults toempty
) — List of fields that should be returned aspandas.Categorical
. Only applies to table-like data structures. -
zero_copy_only (
bool
, defaults toFalse
) — Raise anArrowException
if this function call would require copying the underlying data. -
integer_object_nulls (
bool
, defaults toFalse
) — Cast integers with nulls to objects. -
date_as_object (
bool
, defaults toTrue
) — Cast dates to objects. IfFalse
, convert todatetime64[ns]
dtype. -
timestamp_as_object (
bool
, defaults toFalse
) — Cast non-nanosecond timestamps (np.datetime64
) to objects. This is useful if you have timestamps that don’t fit in the normal date range of nanosecond timestamps (1678 CE-2262 CE). IfFalse
, all timestamps are converted todatetime64[ns]
dtype. -
use_threads (
bool
, defaults toTrue
) — Whether to parallelize the conversion using multiple threads. -
deduplicate_objects (
bool
, defaults toFalse
) — Do not create multiple copies Python objects when created, to save on memory use. Conversion will be slower. -
ignore_metadata (
bool
, defaults toFalse
) — IfTrue
, do not use the ‘pandas’ metadata to reconstruct the DataFrame index, if present. -
safe (
bool
, defaults toTrue
) — For certain data types, a cast is needed in order to store the data in a pandas DataFrame or Series (e.g. timestamps are always stored as nanoseconds in pandas). This option controls whether it is a safe cast or not. -
split_blocks (
bool
, defaults toFalse
) — IfTrue
, generate one internal “block” for each column when creating a pandas.DataFrame from aRecordBatch
orTable
. While this can temporarily reduce memory note that various pandas operations can trigger “consolidation” which may balloon memory use. -
self_destruct (
bool
, defaults toFalse
) — EXPERIMENTAL: IfTrue
, attempt to deallocate the originating Arrow memory while converting the Arrow object to pandas. If you use the object after callingto_pandas
with this option it will crash your program. -
types_mapper (
function
, defaults toNone
) — A function mapping a pyarrow DataType to a pandasExtensionDtype
. This can be used to override the default pandas type for conversion of built-in pyarrow types or in absence ofpandas_metadata
in the Table schema. The function receives a pyarrow DataType and is expected to return a pandasExtensionDtype
orNone
if the default conversion should be used for that type. If you have a dictionary mapping, you can passdict.get
as function.
Returns
pandas.Series
or pandas.DataFrame
pandas.Series
or pandas.DataFrame
depending on type of object
Convert to a pandas-compatible NumPy array or DataFrame, as appropriate.
field
< source >( *args **kwargs )
Select a schema field by its column name or numeric index.
column
< source >( *args **kwargs )
Select a column by its column name, or numeric index.
Iterator over all columns in their numerical order.
Schema of the table and its columns.
List of all columns in numerical order.
Number of columns in this table.
Number of rows in this table.
Due to the definition of a table, all columns have the same number of rows.
Dimensions of the table: (#rows, #columns).
Total number of bytes consumed by the elements of the table.
InMemoryTable
The table is said in-memory when it is loaded into the user’s RAM.
Pickling it does copy all the data using memory. Its implementation is simple and uses the underlying pyarrow Table methods directly.
This is different from the MemoryMapped
table, for which pickling doesn’t copy all the
data in memory. For a MemoryMapped
, unpickling instead reloads the table from the disk.
InMemoryTable
must be used when data fit in memory, while MemoryMapped
are reserved for
data bigger than memory or when you want the memory footprint of your application to
stay low.
validate
< source >( *args **kwargs )
Perform validation checks. An exception is raised if validation fails.
By default only cheap validation checks are run. Pass full=True
for thorough validation checks (potentially O(n)
).
equals
< source >(
*args
**kwargs
)
→
bool
Parameters
- other (Table) — Table to compare against.
-
check_metadata
bool
, defaults toFalse
) — Whether schema metadata equality should be checked as well.
Returns
bool
Check if contents of two tables are equal.
to_batches
< source >( *args **kwargs )
Convert Table to list of (contiguous) RecordBatch
objects.
Convert the Table to a dict
or OrderedDict
.
to_pandas
< source >(
*args
**kwargs
)
→
pandas.Series
or pandas.DataFrame
Parameters
-
memory_pool (
MemoryPool
, defaults toNone
) — Arrow MemoryPool to use for allocations. Uses the default memory pool is not passed. -
strings_to_categorical (
bool
, defaults toFalse
) — Encode string (UTF8) and binary types topandas.Categorical
. -
categories (
list
, defaults toempty
) — List of fields that should be returned aspandas.Categorical
. Only applies to table-like data structures. -
zero_copy_only (
bool
, defaults toFalse
) — Raise anArrowException
if this function call would require copying the underlying data. -
integer_object_nulls (
bool
, defaults toFalse
) — Cast integers with nulls to objects. -
date_as_object (
bool
, defaults toTrue
) — Cast dates to objects. IfFalse
, convert todatetime64[ns]
dtype. -
timestamp_as_object (
bool
, defaults toFalse
) — Cast non-nanosecond timestamps (np.datetime64
) to objects. This is useful if you have timestamps that don’t fit in the normal date range of nanosecond timestamps (1678 CE-2262 CE). IfFalse
, all timestamps are converted todatetime64[ns]
dtype. -
use_threads (
bool
, defaults toTrue
) — Whether to parallelize the conversion using multiple threads. -
deduplicate_objects (
bool
, defaults toFalse
) — Do not create multiple copies Python objects when created, to save on memory use. Conversion will be slower. -
ignore_metadata (
bool
, defaults toFalse
) — IfTrue
, do not use the ‘pandas’ metadata to reconstruct the DataFrame index, if present. -
safe (
bool
, defaults toTrue
) — For certain data types, a cast is needed in order to store the data in a pandas DataFrame or Series (e.g. timestamps are always stored as nanoseconds in pandas). This option controls whether it is a safe cast or not. -
split_blocks (
bool
, defaults toFalse
) — IfTrue
, generate one internal “block” for each column when creating a pandas.DataFrame from aRecordBatch
orTable
. While this can temporarily reduce memory note that various pandas operations can trigger “consolidation” which may balloon memory use. -
self_destruct (
bool
, defaults toFalse
) — EXPERIMENTAL: IfTrue
, attempt to deallocate the originating Arrow memory while converting the Arrow object to pandas. If you use the object after callingto_pandas
with this option it will crash your program. -
types_mapper (
function
, defaults toNone
) — A function mapping a pyarrow DataType to a pandasExtensionDtype
. This can be used to override the default pandas type for conversion of built-in pyarrow types or in absence ofpandas_metadata
in the Table schema. The function receives a pyarrow DataType and is expected to return a pandasExtensionDtype
orNone
if the default conversion should be used for that type. If you have a dictionary mapping, you can passdict.get
as function.
Returns
pandas.Series
or pandas.DataFrame
pandas.Series
or pandas.DataFrame
depending on type of object
Convert to a pandas-compatible NumPy array or DataFrame, as appropriate.
field
< source >( *args **kwargs )
Select a schema field by its column name or numeric index.
column
< source >( *args **kwargs )
Select a column by its column name, or numeric index.
Iterator over all columns in their numerical order.
Schema of the table and its columns.
List of all columns in numerical order.
Number of columns in this table.
Number of rows in this table.
Due to the definition of a table, all columns have the same number of rows.
Dimensions of the table: (#rows, #columns).
Total number of bytes consumed by the elements of the table.
Names of the table’s columns.
slice
< source >( offset = 0 length = None )
Compute zero-copy slice of this Table.
Select records from a Table. See pyarrow.compute.filter
for full usage.
flatten
< source >( *args **kwargs )
Flatten this Table. Each column with a struct type is flattened into one column per struct field. Other columns are left unchanged.
combine_chunks
< source >( *args **kwargs )
Make a new table by combining the chunks this table has.
All the underlying chunks in the ChunkedArray
of each column are
concatenated into zero or one chunk.
cast
< source >( *args **kwargs )
Cast table values to another schema.
replace_schema_metadata
< source >(
*args
**kwargs
)
→
datasets.table.Table
EXPERIMENTAL: Create shallow copy of table by replacing schema
key-value metadata with the indicated new metadata (which may be None
,
which deletes any existing metadata).
add_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Add column to Table at position.
A new table is returned with the column added, the original table object is left unchanged.
append_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Append column at end of columns.
remove_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Create new Table with the indicated column removed.
set_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Replace column in Table at position.
Create new table with columns renamed to provided names.
select
< source >( *args **kwargs ) → datasets.table.Table
Parameters
Returns
New table with the specified columns, and metadata preserved.
Select columns of the table.
Returns a new table with the specified columns, and metadata preserved.
drop
< source >(
*args
**kwargs
)
→
datasets.table.Table
Drop one or more columns and return a new table.
from_pandas
< source >(
*args
**kwargs
)
→
datasets.table.Table
Parameters
-
df (
pandas.DataFrame
) — -
schema (
pyarrow.Schema
, optional) — The expected schema of the Arrow Table. This can be used to indicate the type of columns if we cannot infer it automatically. If passed, the output will have exactly this schema. Columns specified in the schema that are not found in the DataFrame columns or its index will raise an error. Additional columns or index levels in the DataFrame which are not specified in the schema will be ignored. -
preserve_index (
bool
, optional) — Whether to store the index as an additional column in the resultingTable
. The default of None will store the index as a column, except for RangeIndex which is stored as metadata only. Usepreserve_index=True
to force it to be stored as a column. -
nthreads (
int
, defaults toNone
(may use up to system CPU count threads)) — If greater than 1, convert columns to Arrow in parallel using indicated number of threads. -
columns (
List[str]
, optional) — List of column to be converted. IfNone
, use all columns. -
safe (
bool
, defaults toTrue
) — Check for overflows or other unsafe conversions,
Returns
datasets.table.Table
Convert pandas.DataFrame to an Arrow Table.
The column types in the resulting Arrow Table are inferred from the
dtypes of the pandas.Series in the DataFrame. In the case of non-object
Series, the NumPy dtype is translated to its Arrow equivalent. In the
case of object
, we need to guess the datatype by looking at the
Python objects in this Series.
Be aware that Series of the object
dtype don’t carry enough
information to always lead to a meaningful Arrow type. In the case that
we cannot infer a type, e.g. because the DataFrame is of length 0 or
the Series only contains None/nan
objects, the type is set to
null. This behavior can be avoided by constructing an explicit schema
and passing it to this function.
from_arrays
< source >( *args **kwargs )
Parameters
-
arrays (
List[Union[pyarrow.Array, pyarrow.ChunkedArray]]
) — Equal-length arrays that should form the table. -
names (
List[str]
, optional) — Names for the table columns. If not passed, schema must be passed. -
schema (
Schema
, defaults toNone
) — Schema for the created table. If not passed, names must be passed. -
metadata (
Union[dict, Mapping]
, defaults toNone
) — Optional metadata for the schema (if inferred).
Construct a Table from Arrow arrays.
from_pydict
< source >( *args **kwargs )
Construct a Table from Arrow arrays or columns.
from_batches
< source >(
*args
**kwargs
)
→
datasets.table.Table
Construct a Table from a sequence or iterator of Arrow RecordBatches
.
MemoryMappedTable
class datasets.table.MemoryMappedTable
< source >( table: Table path: str replays: typing.Union[typing.List[typing.Tuple[str, tuple, dict]], NoneType] = None )
The table is said memory mapped when it doesn’t use the user’s RAM but loads the data from the disk instead.
Pickling it doesn’t copy the data into memory. Instead, only the path to the memory mapped arrow file is pickled, as well as the list of transforms to “replay” when reloading the table from the disk.
Its implementation requires to store an history of all the transforms that were applied to the underlying pyarrow Table, so that they can be “replayed” when reloading the Table from the disk.
This is different from the InMemoryTable
table, for which pickling does copy all the
data in memory.
InMemoryTable
must be used when data fit in memory, while MemoryMapped
are reserved for
data bigger than memory or when you want the memory footprint of your application to
stay low.
validate
< source >( *args **kwargs )
Perform validation checks. An exception is raised if validation fails.
By default only cheap validation checks are run. Pass full=True
for thorough validation checks (potentially O(n)
).
equals
< source >(
*args
**kwargs
)
→
bool
Parameters
- other (Table) — Table to compare against.
-
check_metadata
bool
, defaults toFalse
) — Whether schema metadata equality should be checked as well.
Returns
bool
Check if contents of two tables are equal.
to_batches
< source >( *args **kwargs )
Convert Table to list of (contiguous) RecordBatch
objects.
Convert the Table to a dict
or OrderedDict
.
to_pandas
< source >(
*args
**kwargs
)
→
pandas.Series
or pandas.DataFrame
Parameters
-
memory_pool (
MemoryPool
, defaults toNone
) — Arrow MemoryPool to use for allocations. Uses the default memory pool is not passed. -
strings_to_categorical (
bool
, defaults toFalse
) — Encode string (UTF8) and binary types topandas.Categorical
. -
categories (
list
, defaults toempty
) — List of fields that should be returned aspandas.Categorical
. Only applies to table-like data structures. -
zero_copy_only (
bool
, defaults toFalse
) — Raise anArrowException
if this function call would require copying the underlying data. -
integer_object_nulls (
bool
, defaults toFalse
) — Cast integers with nulls to objects. -
date_as_object (
bool
, defaults toTrue
) — Cast dates to objects. IfFalse
, convert todatetime64[ns]
dtype. -
timestamp_as_object (
bool
, defaults toFalse
) — Cast non-nanosecond timestamps (np.datetime64
) to objects. This is useful if you have timestamps that don’t fit in the normal date range of nanosecond timestamps (1678 CE-2262 CE). IfFalse
, all timestamps are converted todatetime64[ns]
dtype. -
use_threads (
bool
, defaults toTrue
) — Whether to parallelize the conversion using multiple threads. -
deduplicate_objects (
bool
, defaults toFalse
) — Do not create multiple copies Python objects when created, to save on memory use. Conversion will be slower. -
ignore_metadata (
bool
, defaults toFalse
) — IfTrue
, do not use the ‘pandas’ metadata to reconstruct the DataFrame index, if present. -
safe (
bool
, defaults toTrue
) — For certain data types, a cast is needed in order to store the data in a pandas DataFrame or Series (e.g. timestamps are always stored as nanoseconds in pandas). This option controls whether it is a safe cast or not. -
split_blocks (
bool
, defaults toFalse
) — IfTrue
, generate one internal “block” for each column when creating a pandas.DataFrame from aRecordBatch
orTable
. While this can temporarily reduce memory note that various pandas operations can trigger “consolidation” which may balloon memory use. -
self_destruct (
bool
, defaults toFalse
) — EXPERIMENTAL: IfTrue
, attempt to deallocate the originating Arrow memory while converting the Arrow object to pandas. If you use the object after callingto_pandas
with this option it will crash your program. -
types_mapper (
function
, defaults toNone
) — A function mapping a pyarrow DataType to a pandasExtensionDtype
. This can be used to override the default pandas type for conversion of built-in pyarrow types or in absence ofpandas_metadata
in the Table schema. The function receives a pyarrow DataType and is expected to return a pandasExtensionDtype
orNone
if the default conversion should be used for that type. If you have a dictionary mapping, you can passdict.get
as function.
Returns
pandas.Series
or pandas.DataFrame
pandas.Series
or pandas.DataFrame
depending on type of object
Convert to a pandas-compatible NumPy array or DataFrame, as appropriate.
field
< source >( *args **kwargs )
Select a schema field by its column name or numeric index.
column
< source >( *args **kwargs )
Select a column by its column name, or numeric index.
Iterator over all columns in their numerical order.
Schema of the table and its columns.
List of all columns in numerical order.
Number of columns in this table.
Number of rows in this table.
Due to the definition of a table, all columns have the same number of rows.
Dimensions of the table: (#rows, #columns).
Total number of bytes consumed by the elements of the table.
Names of the table’s columns.
slice
< source >( offset = 0 length = None )
Compute zero-copy slice of this Table.
Select records from a Table. See pyarrow.compute.filter
for full usage.
flatten
< source >( *args **kwargs )
Flatten this Table. Each column with a struct type is flattened into one column per struct field. Other columns are left unchanged.
combine_chunks
< source >( *args **kwargs )
Make a new table by combining the chunks this table has.
All the underlying chunks in the ChunkedArray of each column are concatenated into zero or one chunk.
cast
< source >( *args **kwargs )
Cast table values to another schema
replace_schema_metadata
< source >(
*args
**kwargs
)
→
datasets.table.Table
EXPERIMENTAL: Create shallow copy of table by replacing schema key-value metadata with the indicated new metadata (which may be None, which deletes any existing metadata.
add_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Add column to Table at position.
A new table is returned with the column added, the original table object is left unchanged.
append_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Append column at end of columns.
remove_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Create new Table with the indicated column removed.
set_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Replace column in Table at position.
Create new table with columns renamed to provided names.
select
< source >( *args **kwargs ) → datasets.table.Table
Parameters
Returns
New table with the specified columns, and metadata preserved.
Select columns of the table.
Returns a new table with the specified columns, and metadata preserved.
drop
< source >(
*args
**kwargs
)
→
datasets.table.Table
Drop one or more columns and return a new table.
ConcatenationTable
class datasets.table.ConcatenationTable
< source >( table: Table blocks: typing.List[typing.List[datasets.table.TableBlock]] )
The table comes from the concatenation of several tables called blocks. It enables concatenation on both axis 0 (append rows) and axis 1 (append columns).
The underlying tables are called “blocks” and can be either InMemoryTable
or MemoryMappedTable
objects.
This allows to combine tables that come from memory or that are memory mapped.
When a ConcatenationTable
is pickled, then each block is pickled:
- the
InMemoryTable
objects are pickled by copying all the data in memory. - the MemoryMappedTable objects are pickled without copying the data into memory. Instead, only the path to the memory mapped arrow file is pickled, as well as the list of transforms to “replays” when reloading the table from the disk.
Its implementation requires to store each block separately.
The blocks
attributes stores a list of list of blocks.
The first axis concatenates the tables along the axis 0 (it appends rows),
while the second axis concatenates tables along the axis 1 (it appends columns).
If some columns are missing when concatenating on axis 0, they are filled with null values.
This is done using pyarrow.concat_tables(tables, promote=True)
.
You can access the fully combined table by accessing the ConcatenationTable.table
attribute,
and the blocks by accessing the ConcatenationTable.blocks
attribute.
validate
< source >( *args **kwargs )
Perform validation checks. An exception is raised if validation fails.
By default only cheap validation checks are run. Pass full=True
for thorough validation checks (potentially O(n)
).
equals
< source >(
*args
**kwargs
)
→
bool
Parameters
- other (Table) — Table to compare against.
-
check_metadata
bool
, defaults toFalse
) — Whether schema metadata equality should be checked as well.
Returns
bool
Check if contents of two tables are equal.
to_batches
< source >( *args **kwargs )
Convert Table to list of (contiguous) RecordBatch
objects.
Convert the Table to a dict
or OrderedDict
.
to_pandas
< source >(
*args
**kwargs
)
→
pandas.Series
or pandas.DataFrame
Parameters
-
memory_pool (
MemoryPool
, defaults toNone
) — Arrow MemoryPool to use for allocations. Uses the default memory pool is not passed. -
strings_to_categorical (
bool
, defaults toFalse
) — Encode string (UTF8) and binary types topandas.Categorical
. -
categories (
list
, defaults toempty
) — List of fields that should be returned aspandas.Categorical
. Only applies to table-like data structures. -
zero_copy_only (
bool
, defaults toFalse
) — Raise anArrowException
if this function call would require copying the underlying data. -
integer_object_nulls (
bool
, defaults toFalse
) — Cast integers with nulls to objects. -
date_as_object (
bool
, defaults toTrue
) — Cast dates to objects. IfFalse
, convert todatetime64[ns]
dtype. -
timestamp_as_object (
bool
, defaults toFalse
) — Cast non-nanosecond timestamps (np.datetime64
) to objects. This is useful if you have timestamps that don’t fit in the normal date range of nanosecond timestamps (1678 CE-2262 CE). IfFalse
, all timestamps are converted todatetime64[ns]
dtype. -
use_threads (
bool
, defaults toTrue
) — Whether to parallelize the conversion using multiple threads. -
deduplicate_objects (
bool
, defaults toFalse
) — Do not create multiple copies Python objects when created, to save on memory use. Conversion will be slower. -
ignore_metadata (
bool
, defaults toFalse
) — IfTrue
, do not use the ‘pandas’ metadata to reconstruct the DataFrame index, if present. -
safe (
bool
, defaults toTrue
) — For certain data types, a cast is needed in order to store the data in a pandas DataFrame or Series (e.g. timestamps are always stored as nanoseconds in pandas). This option controls whether it is a safe cast or not. -
split_blocks (
bool
, defaults toFalse
) — IfTrue
, generate one internal “block” for each column when creating a pandas.DataFrame from aRecordBatch
orTable
. While this can temporarily reduce memory note that various pandas operations can trigger “consolidation” which may balloon memory use. -
self_destruct (
bool
, defaults toFalse
) — EXPERIMENTAL: IfTrue
, attempt to deallocate the originating Arrow memory while converting the Arrow object to pandas. If you use the object after callingto_pandas
with this option it will crash your program. -
types_mapper (
function
, defaults toNone
) — A function mapping a pyarrow DataType to a pandasExtensionDtype
. This can be used to override the default pandas type for conversion of built-in pyarrow types or in absence ofpandas_metadata
in the Table schema. The function receives a pyarrow DataType and is expected to return a pandasExtensionDtype
orNone
if the default conversion should be used for that type. If you have a dictionary mapping, you can passdict.get
as function.
Returns
pandas.Series
or pandas.DataFrame
pandas.Series
or pandas.DataFrame
depending on type of object
Convert to a pandas-compatible NumPy array or DataFrame, as appropriate.
field
< source >( *args **kwargs )
Select a schema field by its column name or numeric index.
column
< source >( *args **kwargs )
Select a column by its column name, or numeric index.
Iterator over all columns in their numerical order.
Schema of the table and its columns.
List of all columns in numerical order.
Number of columns in this table.
Number of rows in this table.
Due to the definition of a table, all columns have the same number of rows.
Dimensions of the table: (#rows, #columns).
Total number of bytes consumed by the elements of the table.
Names of the table’s columns.
slice
< source >( offset = 0 length = None )
Compute zero-copy slice of this Table.
Select records from a Table. See pyarrow.compute.filter
for full usage.
flatten
< source >( *args **kwargs )
Flatten this Table. Each column with a struct type is flattened into one column per struct field. Other columns are left unchanged.
combine_chunks
< source >( *args **kwargs )
Make a new table by combining the chunks this table has.
All the underlying chunks in the ChunkedArray
of each column are
concatenated into zero or one chunk.
cast
< source >( target_schema *args **kwargs )
Cast table values to another schema.
replace_schema_metadata
< source >(
*args
**kwargs
)
→
datasets.table.Table
EXPERIMENTAL: Create shallow copy of table by replacing schema
key-value metadata with the indicated new metadata (which may be None
,
which deletes any existing metadata).
add_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Add column to Table at position.
A new table is returned with the column added, the original table object is left unchanged.
append_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Append column at end of columns.
remove_column
< source >(
i
*args
**kwargs
)
→
datasets.table.Table
Create new Table with the indicated column removed.
set_column
< source >(
*args
**kwargs
)
→
datasets.table.Table
Replace column in Table at position.
Create new table with columns renamed to provided names.
select
< source >( columns *args **kwargs ) → datasets.table.Table
Parameters
Returns
New table with the specified columns, and metadata preserved.
Select columns of the table.
Returns a new table with the specified columns, and metadata preserved.
drop
< source >(
columns
*args
**kwargs
)
→
datasets.table.Table
Drop one or more columns and return a new table.
from_tables
< source >( tables: typing.List[typing.Union[pyarrow.lib.Table, datasets.table.Table]] axis: int = 0 )
Create ConcatenationTable
from list of tables.
Utils
datasets.table.concat_tables
< source >(
tables: typing.List[datasets.table.Table]
axis: int = 0
)
→
datasets.table.Table
Parameters
-
tables (list of
Table
) — List of tables to be concatenated. -
axis (
{0, 1}
, defaults to0
, meaning over rows) — Axis to concatenate over, where0
means over rows (vertically) and1
means over columns (horizontally).Added in 1.6.0
Returns
datasets.table.Table
If the number of input tables is > 1, then the returned table is a datasets.table.ConcatenationTable
.
Otherwise if there’s only one table, it is returned as is.
Concatenate tables.
datasets.table.list_table_cache_files
< source >(
table: Table
)
→
List[str]
Returns
List[str]
A list of paths to the cache files loaded by the table.
Get the cache files that are loaded by the table. Cache file are used when parts of the table come from the disk via memory mapping.