LoadConfig

class google_pandas_load.load_config.LoadConfig(source: str, destination: str, data_name: Optional[str] = None, query: Optional[str] = None, dataframe: Optional[pandas.core.frame.DataFrame] = None, write_disposition: Optional[str] = 'WRITE_TRUNCATE', dtype: Optional[Dict[str, Any]] = None, parse_dates: Optional[List[str]] = None, date_cols: Optional[List[str]] = None, timestamp_cols: Optional[List[str]] = None, bq_schema: Optional[List[google.cloud.bigquery.schema.SchemaField]] = 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: pandas.core.frame.DataFrame, date_cols: Optional[List[str]] = None, timestamp_cols: Optional[List[str]] = None) List[google.cloud.bigquery.schema.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