geost.accessor.GeostFrame.select_by_values#
- GeostFrame.select_by_values(column: str, values: int | float | str | Iterable | slice, how: str = 'or', invert: bool = False, inclusive: str = 'both') DataFrame[source]#
Select data based on the presence of values in a given column. Can be used for example to select data that contain peat in the lithology column.
- Parameters:
column (str) – Name of the column to look for the selection values in.
values (int | float | str | Iterable | slice) – Value or array-like set of values to look for in the column. In case of numerical values, a slice can be used to select data that contain a specific range of values, see example below.
how ({"and", "or"}, optional) – Either “and” or “or”, only used when multiple categorical values are provided. “and” requires all selection values to be present in the column for selection. “or” will select the data if any one of the values are found in the column. The default is “and”.
invert (bool, optional) – If True, the selection is inverted so that data that does not match the selection criteria is returned instead. The default is False.
inclusive ({"both", "neither", "left", "right"}, optional) – When a slice is used for selection to include boundaries or not. The default is “both”.
- Returns:
New DataFrame containing only the data selected by this method.
- Return type:
pd.DataFrame
Examples
To select data where both clay (“K”) and peat (“V”) are present at the same time, use “and” as a selection method:
>>> selection = data.gst.select_by_values("lith", ["V", "K"], how="and")
To select data that can have one, or both lithologies, use or as the selection method:
>>> selection = data.gst.select_by_values("lith", ["V", "K"], how="or")
In case of numerical values, use a slice to select data that contain a specific range of values. For example, to select data that contain cone resistances (“qc”) between 15 and 20 MPa:
>>> selection = data.gst.select_by_values("qc", slice(15, 20))