API Reference
- pantab.frame_from_hyper(source: str | Path, *, table: str | TableauName | TableauTableName, return_type: Literal['pandas', 'polars', 'pyarrow', 'stream'] = 'pandas', process_params: dict[str, str] | None = None, chunk_size=0)
Extracts a DataFrame from a .hyper extract.
- Parameters:
source (
Union[str,Path]) – Name / location of the Hyper file to be read or Hyper-API connection.table (
Union[str,TableauName,TableauTableName]) – Table to read.return_type (
Literal['pandas','polars','pyarrow','stream']) – The type of DataFrame to be returnedprocess_params (
Optional[dict[str,str]]) – Parameters to pass to the Hyper Process constructor.chunk_size – When returning a stream, the number of rows in each chunk to be read
- pantab.frame_from_hyper_query(source: str | Path, query: str, *, return_type: Literal['pandas', 'polars', 'pyarrow', 'stream'] = 'pandas', process_params: dict[str, str] | None = None, chunk_size=0)
Executes a SQL query and returns the result as a pandas dataframe
- Parameters:
source (
Union[str,Path]) – Name / location of the Hyper file to be read or Hyper-API connection.query (
str) – SQL query to execute.return_type (
Literal['pandas','polars','pyarrow','stream']) – The type of result to be returnedprocess_params (
Optional[dict[str,str]]) – Parameters to pass to the Hyper Process constructor.chunk_size – When returning a stream, the number of rows in each chunk to be read
- pantab.frame_to_hyper(df, database: str | Path, *, table: str | TableauName | TableauTableName, table_mode: Literal['a', 'w'] = 'w', not_null_columns: set[str] | None = None, json_columns: set[str] | None = None, geo_columns: set[str] | None = None, process_params: dict[str, str] | None = None, atomic: bool = True) None
Convert a DataFrame to a .hyper extract.
- Parameters:
df – Data to be written out.
database (
Union[str,Path]) – Name / location of the Hyper file to write to.table (
Union[str,TableauName,TableauTableName]) – Table to write to.table_mode (
Literal['a','w']) – The mode to open the table with. Default is “w” for write, which truncates the file before writing. Another option is “a”, which will append data to the file if it already contains information.not_null_columns (
Optional[set[str]]) – Columns which should be considered “NOT NULL” in the target Hyper database. By default, all columns are considered nullablejson_columns (
Optional[set[str]]) – Columns to be written as a JSON data typegeo_columns (
Optional[set[str]]) – Columns to be written as a GEOGRAPHY data typeprocess_params (
Optional[dict[str,str]]) – Parameters to pass to the Hyper Process constructor.atomic (
bool) – Whether to treat write as atomic. Disabling gives better performance, but failures during write will likely corrupt the Hyper file.
- Return type:
None
- pantab.frames_from_hyper(source: str | Path, return_type: Literal['pandas', 'polars', 'pyarrow', 'stream'] = 'pandas', process_params: dict[str, str] | None = None, chunk_size=0)
Extracts tables from a .hyper extract.
- Parameters:
source (
Union[str,Path]) – Name / location of the Hyper file to be read or Hyper-API connection.return_type (
Literal['pandas','polars','pyarrow','stream']) – The type of DataFrame to be returnedprocess_params (
Optional[dict[str,str]]) – Parameters to pass to the Hyper Process constructor.chunk_size – When returning a stream, the number of rows in each chunk to be read
- pantab.frames_to_hyper(dict_of_frames: dict[str | TableauName | TableauTableName, Any], database: str | Path, *, table_mode: Literal['a', 'w'] = 'w', not_null_columns: set[str] | None = None, json_columns: set[str] | None = None, geo_columns: set[str] | None = None, process_params: dict[str, str] | None = None, atomic: bool = True) None
Writes multiple DataFrames to a .hyper extract.
- Parameters:
dict_of_frames (
dict[Union[str,TableauName,TableauTableName],Any]) – A dictionary whose keys are valid table identifiers and values are dataframesdatabase (
Union[str,Path]) – Name / location of the Hyper file to write to.table_mode (
Literal['a','w']) – The mode to open the table with. Default is “w” for write, which truncates the file before writing. Another option is “a”, which will append data to the file if it already contains information.not_null_columns (
Optional[set[str]]) – Columns which should be considered “NOT NULL” in the target Hyper database. By default, all columns are considered nullablejson_columns (
Optional[set[str]]) – Columns to be written as a JSON data typegeo_columns (
Optional[set[str]]) – Columns to be written as a GEOGRAPHY data typeprocess_params (
Optional[dict[str,str]]) – Parameters to pass to the Hyper Process constructor.atomic (
bool) – Whether to treat write as atomic. Disabling gives better performance, but failures during write will likely corrupt the Hyper file.
- Return type:
None