LoadConfig

class google_pandas_load.load_config.LoadConfig(source: Literal['query', 'dataset', 'bucket', 'local', 'dataframe'], destination: Literal['dataset', 'bucket', 'local', 'dataframe'], data_name: str | None = None, query: str | None = None, dataframe: DataFrame | None = None, write_disposition: str | None = 'WRITE_TRUNCATE', dtype: Dict[str, Any] | None = None, parse_dates: List[str] | None = None, date_cols: List[str] | None = None, timestamp_cols: List[str] | None = None, bq_schema: List[SchemaField] | None = None)[source]

Bases: object

Configuration for a load job.

This class has the same parameters as google_pandas_load.loader.Loader.load(). It is used to launch simultaneously load jobs as follows:

static bq_schema_inferred_from_dataframe(dataframe: DataFrame, date_cols: List[str] | None = None, timestamp_cols: List[str] | None = None) List[SchemaField][source]

Return a BigQuery schema that is inferred from a pandas dataframe.

Let infer_dtype(column) = pandas.api.types.infer_dtype (column).

In BigQuery, a column is given its type according to the following rule:

  • if its name is listed in the date_cols parameter, its type in BigQuery should be DATE.

  • elif its name is listed in the timestamp_cols parameter, its type in BigQuery should be TIMESTAMP.

  • elif infer_dtype(column) = ‘boolean’, its type in BigQuery is BOOLEAN.

  • elif infer_dtype(column) = ‘integer’, its type in BigQuery is INTEGER.

  • elif infer_dtype(column) = ‘floating’, its type in BigQuery is FLOAT.

  • else its type in BigQuery is STRING.

Parameters:
  • dataframe (pandas.DataFrame) – The dataframe.

  • date_cols (list of str, optional) – The names of the columns receiving the BigQuery type DATE.

  • timestamp_cols (list of str, optional) – The names of the columns receiving the BigQuery type TIMESTAMP.

Returns:

A BigQuery schema.

Return type:

list of google.cloud.bigquery.schema.SchemaField