fips.Space.round_labels#
- Space.round_labels(decimals)[source]#
Return the space with every float level rounded to decimals places.
fips never rounds labels on its own. Round them on purpose when two sources give the same coordinate with different float noise (a grid written by two programs, say), so that their labels match.
- Parameters:
decimals (
int) – Number of decimal places. Levels that are not floats are kept.- Returns:
The space with rounded labels.
- Return type:
- Raises:
ValueError – If rounding makes two labels of a block equal. The message names the labels that merged.
Examples
>>> import pandas as pd >>> from fips import Space >>> space = Space({"flux": pd.Index([40.7600001, 40.77], name="lat")}) >>> space.round_labels(4).select("flux") Index([40.76, 40.77], dtype='float64', name='lat')