bach.DataFrame.from_table

classmethod from_table

(engine, table_name, index, all_dtypes=None, name_to_column_mapping=None)

[source]

Instantiate a new DataFrame based on the content of an existing table in the database.

If all_dtypes is not specified, the column dtypes are queried from the database’s information schema.

Parameters

  • engine (sqlalchemy.engine.base.Engine) – a sqlalchemy engine for the database.
  • table_name (str) – the table name that contains the data to instantiate as DataFrame. Can include project_id and dataset on BigQuery, e.g. ‘project_id.dataset.table_name’.
  • index (List[str]) – list of series names that make up the index. At least one series needs to be selected for the index.
  • all_dtypes (Optional[Mapping[str, Union[List[Any], Mapping[str, Any], str]]]) – Optional. Mapping from series name to dtype. Must contain all index and data series. Must be in same order as the columns appear in the sql-model.
  • name_to_column_mapping (Optional[Mapping[str, str]]) – Optional mapping from series names to the actual column names in the table. If mapping is None or missing a specific name, then the column name is assumed to be the same as the series name.

Returns

A DataFrame based on a sql table.

Return type

bach.dataframe.DataFrame

note

If all_dtypes is not set, then this will query the database.