LoadConfig

class google_pandas_load.load_config.LoadConfig(source, destination, data_name=None, query=None, dataframe=None, write_disposition='WRITE_TRUNCATE', dtype=None, parse_dates=None, date_cols=None, timestamp_cols=None, bq_schema=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, date_cols=None, timestamp_cols=None)[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