bigframes.bigquery.ai.if_#

bigframes.bigquery.ai.if_(prompt: str | Series | Series | List[str | Series | Series] | Tuple[str | Series | Series, ...], *, connection_id: str | None = None) Series[source]#

Evaluates the prompt to True or False. Compared to ai.generate_bool(), this function provides optimization such that not all rows are evaluated with the LLM.

Examples:

>>> import bigframes.pandas as bpd
>>> import bigframes.bigquery as bbq
>>> us_state = bpd.Series(["Massachusetts", "Illinois", "Hawaii"])
>>> bbq.ai.if_((us_state, " has a city called Springfield"))
0     True
1     True
2    False
dtype: boolean
>>> us_state[bbq.ai.if_((us_state, " has a city called Springfield"))]
0    Massachusetts
1         Illinois
dtype: string

Note

This product or feature is subject to the “Pre-GA Offerings Terms” in the General Service Terms section of the Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available “as is” and might have limited support. For more information, see the launch stage descriptions (https://cloud.google.com/products#product-launch-stages).

Parameters:
  • prompt (str | Series | List[str|Series] | Tuple[str|Series, ...]) – A mixture of Series and string literals that specifies the prompt to send to the model. The Series can be BigFrames Series or pandas Series.

  • connection_id (str, optional) – Specifies the connection to use to communicate with the model. For example, myproject.us.myconnection. If not provided, the connection from the current session will be used.

Returns:

A new series of bools.

Return type:

bigframes.series.Series