Loading...

vastorbit.core.tablesample.base.TableSample

class vastorbit.core.tablesample.base.TableSample(values: dict | None = None, dtype: dict | None = None, count: int = 0, offset: int = 0, percent: dict | None = None, max_columns: int = -1, col_formats: list[str] | None = None)

TableSample sits at the transition from ‘Big Data’ to ‘Small Data’. This object allows you to conveniently display your results without dependencies on any other modules. It stores the aggregated result in-memory and can then be transformed into a pandas.DataFrame or VastFrame.

Parameters:
  • values (dict, optional) – Dictionary of columns (keys) and their values. The dictionary must be in the following format: {"column1": [val1, ..., valm], ... "columnk": [val1, ..., valm]}

  • dtype (dict, optional) – Columns data types.

  • count (int, optional) – Number of elements to render when loading the entire dataset. This is used only for rendering purposes.

  • offset (int, optional) – Number of elements to skip when loading the entire dataset. This is used only for rendering purposes.

  • percent (dict, optional) – Dictionary of missing values (Used to display the percent bars)

  • max_columns (int, optional) – Maximum number of columns to display.

  • col_formats (list, optional) – How to format the different columns.

Variables:
  • the (The object attributes are)

  • parameters. (same as the input)

Examples

Let’s import the TableSample object:

from vastorbit import TableSample

Let’s build an example object.

# dict with all the data.
d = {
    "customer_ID": [0, 1, 2, 3],
    "age": [40, 30, 22, 55],
    "name": ['Roger', 'Maria', 'Alisia', 'Costi'],
}

# creating the object.
tb = TableSample(d)
customer_IDagename
1040Roger
2130Maria
3222Alisia
4355Costi
Rows: 1-4 | Columns: 3

Let’s use multiple functions.

# Shape.
tb.shape()

# TableSample columns.
tb.get_columns()

# Exporting to list.
tb.to_list()

# Exporting to pandas.DataFrame.
tb.to_pandas()

# Exporting to SQL.
print(tb.to_sql())

Note

Explore TableSample different methods to see more examples.

See also

VastFrame : Main vastorbit dataset object.
__init__(values: dict | None = None, dtype: dict | None = None, count: int = 0, offset: int = 0, percent: dict | None = None, max_columns: int = -1, col_formats: list[str] | None = None) None

Methods

__init__([values, dtype, count, offset, ...])

append(tbs)

Appends the input TableSample to a target TableSample.

category(column)

Returns the category of data in a specified TableSample column.

decimal_to_float()

Converts all the TableSample decimals to floats.

get_columns()

Returns the TableSample columns.

merge(tbs)

Merges the input TableSample to a target TableSample.

narrow([use_number_as_category])

Returns the narrow representation of the TableSample.

read_sql(query[, title, max_columns, ...])

Returns the result of a SQL query as a TableSample object.

shape()

Computes the TableSample shape.

sort(column[, desc])

Sorts the TableSample using the input column.

to_list()

Converts the TableSample to a list.

to_numpy()

Converts the TableSample to a Numpy array.

to_pandas()

Converts the TableSample to a pandas.DataFrame.

to_sql()

Generates the SQL query associated to the TableSample.

to_vdf()

Converts the TableSample to a VastFrame.

transpose()

Transposes the TableSample.

Attributes

object_type