API

class gtable.Table(data={})[source]

Table is a class for fast columnar storage using a bitmap index for sparse storage

add_column(k, v, dtype=None, index=None, align='top')[source]

Column concatenation.

copy()[source]

Returns a copy of the table

crop(key)[source]

Purge the records where the column key is empty

del_column(k)[source]

Column deletion

dropnan(clip=False)[source]

Drop the NaNs and leave missing values instead

fill_column(key, fillvalue)[source]

Fill N/A elements in the given columns with fillvalue

Parameters:
  • key – String, list or tuple with the column names to be filled.
  • fillvalue – Scalar to fill the N/A elements
Returns:

fillna_column(key, reverse=False, fillvalue=None)[source]

Fillna on a column inplace

Parameters:
  • key – string or list
  • reverse
  • fillvalue
Returns:

filter(predicate)[source]

Filter table using a column specification or predicate

first_record(fill=False)[source]

Returns the first record of the table

static from_chunks(chunks)[source]

Create a table from table chunks

Parameters:chunks
Returns:
classmethod from_pandas(dataframe)[source]

Create a table from a pandas dataframe

get(key, copy=False)[source]

Gets a column or a table with columns

last_record(fill=False)[source]

Returns the last record of the table

merge(table, column)[source]

Merge two tables using two dense and sorted columns

records(fill=False)[source]

Generator that returns a dictionary for each row of the table

reduce_by_key(column, check_sorted=False)[source]

Reduce by key

Parameters:
  • column
  • check_sorted
Returns:

rename_column(old_name, new_name)[source]

Rename a column of the table

Parameters:
  • old_name
  • new_name
Returns:

required_column(key, dtype)[source]

Enforce the required column with a dtype

Parameters:
  • key
  • dtype
Returns:

required_columns(*args)[source]

Enforce the required columns. Create empty columns if necessary.

Parameters:args
Returns:
sieve(idx)[source]

Filter table using a one-dimensional array of boolean values

sort_by(column)[source]

Sorts by values of a column

stack(table)[source]

Vertical (Table) concatenation.

to_dict()[source]

Translate the table to a dict {key -> array_of_values}

to_pandas(fill=False)[source]

Translate the table to a pandas dataframe

class gtable.Column(values, index)[source]

Indexed column view of the table

astype(dtype)[source]

Changes the (numpy) datatype of the values

contains(item)[source]

Returns a column with the value of the column present in item.

Parameters:item
Returns:
copy()[source]

Return a copy of the column

date_range(fr='1970-01-01', to='2262-01-01', include_fr=True, include_to=True)[source]

Filter a column by date range.

Parameters:
  • fr
  • to
  • include_fr
  • include_to
Returns:

dtype

Returns the datatype of the column

fill(fillvalue)[source]

Fills the N/A values of the column with the fillvalue :param fillvalue: :return:

fillna(reverse=False, fillvalue=None)[source]

Fills the non available value sequentially with the previous available position. Operates inplace.

is_empty()[source]

True if the column is empty

Returns:
is_sorted()[source]

True if the column is sorted :return:

mask(mask)[source]

Apply mask on data to the data and the index out of place :param mask: :return:

reindex(index)[source]

Reindex according to a global index

Parameters:index
Returns:
reorder(order)[source]

Reorder the column inplace :param order: :return: