find_index_of_value_in_series
- trashpanda.find_index_of_value_in_series(source_series: pandas.core.series.Series, search_value: float) float
Finds the index of an value within a Series. Only float values as search value are supported.
Notes
This method returns the first nearest hit towards the search value within the source series. This method doesn’t detext multiple entries within the source series.
- Parameters
source_series (Series) – Source series in which the nearest index for the search value should be found.
search_value (float) – The search value for which the nearest value’s index should be returned.
- Returns
float
Examples
>>> from pandas import Series, Index >>> import numpy as np >>> sample_series = Series( ... data=[1.0, 2.0, 2.0, 3.0, 4.0], ... index=Index([0.1, 0.2, 0.3, 0.4, 0.5]) ... ) >>> sample_series 0.1 1.0 0.2 2.0 0.3 2.0 0.4 3.0 0.5 4.0 dtype: float64
In general the first nearest hit toward the search value ist returned.
>>> find_index_of_value_in_series(sample_series, -1.0) 0.1 >>> find_index_of_value_in_series(sample_series, 5.0) 0.5
Search values within the range returns the first occurance. In this case 0.3 will never be returned.
>>> find_index_of_value_in_series(sample_series, 2.49) 0.2 >>> find_index_of_value_in_series(sample_series, 2.5) 0.2 >>> find_index_of_value_in_series(sample_series, 2.51) 0.4 >>> find_index_of_value_in_series(sample_series, 3.0) 0.4