bigframes.geopandas.GeoSeries.where#

GeoSeries.where(cond, other=None)#

Replace values where the condition is False.

Examples:

>>> s = bpd.Series([10, 11, 12, 13, 14])
>>> s
0    10
1    11
2    12
3    13
4    14
dtype: Int64

You can filter the values in the Series based on a condition. The values matching the condition would be kept, and not matching would be replaced. The default replacement value is NA.

>>> s.where(s % 2 == 0)
0      10
1    <NA>
2      12
3    <NA>
4      14
dtype: Int64

You can specify a custom replacement value for non-matching values.

>>> s.where(s % 2 == 0, -1)
0    10
1    -1
2    12
3    -1
4    14
dtype: Int64
>>> s.where(s % 2 == 0, 100*s)
0      10
1    1100
2      12
3    1300
4      14
dtype: Int64
Parameters:
  • cond (bool Series/DataFrame, array-like, or callable) – Where cond is True, keep the original value. Where False, replace with corresponding value from other. If cond is callable, it is computed on the Series/DataFrame and returns boolean Series/DataFrame or array. The callable must not change input Series/DataFrame (though pandas doesn’t check it).

  • other (scalar, Series/DataFrame, or callable) – Entries where cond is False are replaced with corresponding value from other. If other is callable, it is computed on the Series/DataFrame and returns scalar or Series/DataFrame. The callable must not change input Series/DataFrame (though pandas doesn’t check it). If not specified, entries will be filled with the corresponding NULL value (np.nan for numpy dtypes, pd.NA for extension dtypes).

Returns:

Series after the replacement.

Return type:

bigframes.pandas.Series