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)¶
TableSamplesits 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 apandas.DataFrameorVastFrame.- Parameters:
values (dict, optional) – Dictionary of columns (keys) and their values. The
dictionarymust 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
TableSampleobject: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_ID age name 1 0 40 Roger 2 1 30 Maria 3 2 22 Alisia 4 3 55 Costi Rows: 1-4 | Columns: 3Let’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
TableSampledifferent 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
TableSampleto a targetTableSample.category(column)Returns the category of data in a specified
TableSamplecolumn.Converts all the
TableSampledecimalstofloats.Returns the TableSample columns.
merge(tbs)Merges the input
TableSampleto a targetTableSample.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
TableSampleobject.shape()Computes the
TableSampleshape.sort(column[, desc])Sorts the TableSample using the input column.
to_list()Converts the
TableSampleto alist.to_numpy()Converts the
TableSampleto a Numpy array.Converts the
TableSampleto apandas.DataFrame.to_sql()Generates the SQL query associated to the
TableSample.to_vdf()Converts the
TableSampleto aVastFrame.Transposes the
TableSample.Attributes
object_type