bigframes.streaming.StreamingDataFrame#
- class bigframes.streaming.StreamingDataFrame(df: DataFrame, *, create_key=0)[source]#
Two-dimensional, size-mutable, potentially heterogeneous tabular data.
Data structure also contains labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects. The primary pandas data structure.
Note
The bigframes.streaming module is a preview feature, and subject to change.
Currently only supports basic projection, filtering and preview operations.
- __getitem__(*args, **kwargs)[source]#
Gets the specified column(s) from the StreamingDataFrame.
- Parameters:
key (index) – Index or list of indices. It can be a column label, a list of column labels, a Series of booleans or a pandas Index of desired column labels
- Returns:
Value(s) at the requested index(es).
- Return type:
bigframes.pandas.Series or Any
- __repr__(*args, **kwargs)[source]#
Converts a StreamingDataFrame to a string. Calls to_pandas.
Only represents the first bigframes.options.display.max_rows.
- __setitem__(*args, **kwargs)[source]#
Modify or insert a column into the StreamingDataFrame.
Note
This does not modify the original table the StreamingDataFrame was derived from.
- Parameters:
key (column index) – It can be a new column to be inserted, or an existing column to be modified.
value (scalar, Sequence, StreamingDataFrame, or Series) – Value to be assigned to the column
- rename(*args, **kwargs)[source]#
Rename columns.
Dict values must be unique (1-to-1). Labels not contained in a dict will be left as-is. Extra labels listed don’t throw an error.
- Parameters:
columns (Mapping) – Dict-like from old column labels to new column labels.
inplace (bool) – Default False. Whether to modify the StreamingDataFrame rather than creating a new one.
- Returns:
StreamingDataFrame with the renamed axis labels or None if
inplace=True.- Return type:
bigframes.pandas.DataFrame | None
- Raises:
KeyError – If any of the labels is not found.
- property sql#
Compiles this StreamingDataFrame’s expression tree to SQL.
- Returns:
string representing the compiled SQL.
- Return type:
- to_bigtable(*, instance: str, table: str, service_account_email: str | None = None, app_profile: str | None = None, truncate: bool = False, overwrite: bool = False, auto_create_column_families: bool = False, bigtable_options: dict | None = None, job_id: str | None = None, job_id_prefix: str | None = None, start_timestamp: int | float | str | datetime | date | None = None, end_timestamp: int | float | str | datetime | date | None = None) QueryJob#
Export the StreamingDataFrame as a continue job and returns a QueryJob object for some management functionality.
This method requires an existing bigtable preconfigured to accept the continuous query export statement. For instructions on export to bigtable, see https://cloud.google.com/bigquery/docs/export-to-bigtable.
- Parameters:
instance (str) – The name of the bigtable instance to export to.
table (str) – The name of the bigtable table to export to.
service_account_email (str) – Full name of the service account to run the continuous query. Example: accountname@projectname.gserviceaccounts.com If not provided, the user account will be used, but this limits the lifetime of the continuous query.
app_profile (str, default None) – The bigtable app profile to export to. If None, no app profile will be used.
truncate (bool, default False) – The export truncate option, see https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements#bigtable_export_option
overwrite (bool, default False) – The export overwrite option, see https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements#bigtable_export_option
auto_create_column_families (bool, default False) – The auto_create_column_families option, see https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements#bigtable_export_option
bigtable_options (dict, default None) – The bigtable options dict, which will be converted to JSON using json.dumps, see https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements#bigtable_export_option If None, no bigtable_options parameter will be passed.
job_id (str, default None) – If specified, replace the default job id for the query, see job_id parameter of https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.client.Client#google_cloud_bigquery_client_Client_query
job_id_prefix (str, default None) – If specified, a job id prefix for the query, see job_id_prefix parameter of https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.client.Client#google_cloud_bigquery_client_Client_query
start_timestamp (int, float, str, datetime, date, default None) – The starting timestamp for the query. Possible values are to 7 days in the past. If don’t specify a timestamp (None), the query will default to the earliest possible time, 7 days ago. If provide a time-zone-naive timestamp, it will be treated as UTC.
- Returns:
See https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryJob The ongoing query job can be managed using this object. For example, the job can be cancelled or its error status can be examined.
- Return type:
google.cloud.bigquery.QueryJob
- to_pubsub(*, topic: str, service_account_email: str, job_id: str | None = None, job_id_prefix: str | None = None, start_timestamp: int | float | str | datetime | date | None = None) QueryJob#
Export the StreamingDataFrame as a continue job and returns a QueryJob object for some management functionality.
This method requires an existing pubsub topic. For instructions on creating a pubsub topic, see https://cloud.google.com/pubsub/docs/samples/pubsub-quickstart-create-topic?hl=en
Note that a service account is a requirement for continuous queries exporting to pubsub.
- Parameters:
topic (str) – The name of the pubsub topic to export to. For example: “taxi-rides”
service_account_email (str) – Full name of the service account to run the continuous query. Example: accountname@projectname.gserviceaccounts.com
job_id (str, default None) – If specified, replace the default job id for the query, see job_id parameter of https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.client.Client#google_cloud_bigquery_client_Client_query
job_id_prefix (str, default None) – If specified, a job id prefix for the query, see job_id_prefix parameter of https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.client.Client#google_cloud_bigquery_client_Client_query
start_timestamp (int, float, str, datetime, date, default None) – The starting timestamp for the query. Possible values are to 7 days in the past. If don’t specify a timestamp (None), the query will default to the earliest possible time, 7 days ago. If provide a time-zone-naive timestamp, it will be treated as UTC.
- Returns:
See https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryJob The ongoing query job can be managed using this object. For example, the job can be cancelled or its error status can be examined.
- Return type:
google.cloud.bigquery.QueryJob