Table object#
- class legate_dataframe.lib.core.table.LogicalTable(columns: Iterable[LogicalColumn], column_names: Iterable[str])#
Collection of logical columns
The order of the collection of columns is preserved. Use .get_column and .get_columns to access individual columns.
Unlike libcudf, the columns in a LogicalTable have names, which makes it possible to retrieve columns by name using .get_column(). Additionally, when reading and writing tables to/from files, the column names are read and written automatically.
Notice, the table doesn’t own the columns, a column can be in multiple tables.
- static from_cudf(df: cudf.DataFrame) LogicalTable #
Create a logical table from a local cudf dataframe
This call blocks the client’s control flow and scatter the data to all legate nodes.
- Parameters:
df (cudf.DataFrame) – cudf dataframe
- Return type:
New logical table
- get_column(self, column: int | str) LogicalColumn #
Returns a reference to the specified column
- Parameters:
column (int or str) – Index or name of the desired column
- Return type:
The desired column
- Raises:
IndexError – If column doesn’t exist
TypeError – If column isn’t a string or integer
OverflowError – If column is a negative integer
- get_column_names(self) List[str] #
Returns a list of the column names order by column indices
- Returns:
A list of the column names
- Return type:
list of str
- num_columns(self) int #
Returns the number of columns
- Return type:
The number of columns
- num_rows(self) int #
Returns the number of rows
- Returns:
The number of rows
- Return type:
int
- Raises:
RuntimeError – if table is unbound
- offload_to(self, cpp_StoreTarget target_mem)#
Offload the underlying data to the specified memory.
This method offloads the underlying data to the specified target memory. The purpose of this is to free up GPU memory resources. See
legate::LogicalArray::offload_to()
for more information.- Parameters:
target_mem (legate.core.StoreTarget) – The memory kind to offload to. To offload to the CPU use
legate.core.StoreTarget.SYSMEM
.
- repr(self, size_t max_num_items=30) str #
Return a printable representational string
- Parameters:
max_num_items (int) – Maximum number of items to include before items are abbreviated.
- Return type:
Printable representational string
- select(self, columns) LogicalTable #
Select a subset of columns from this table.
Similar to
table[columns]
but accepts any iterable.Parameter#
- columns
Iterable of column names or indices.
- returns:
A table with only the selected columns.
- rtype:
table
- to_array(self, *, out=None)#
Convert the table or a set of columns to a cupynumeric array.
The returned array is always a copy.
- Parameters:
out – If given an output cupynumeric array.
- Returns:
A cupynumeric array of shape
(num_rows, num_cols)
.- Return type:
array
- to_cudf(self) cudf.DataFrame #
Copy the logical table into a local cudf table
This call blocks the client’s control flow and fetches the data for the whole table to the current node.
- Returns:
A local cudf dataframe copy.
- Return type: