> ## Documentation Index
> Fetch the complete documentation index at: https://docs.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# relativities.fill

> Every public name in relativities.fill, from its docstrings.

*Generated from the package's Python API.*

Ready ways to fill a study's unknown facts: `fill.like` and `fill.shares`.

`Study(book, fill={...}, draws=n, seed=s)` fills each blank value of a
column, or of a set of columns sampled together, in draws 1 to `n`. Besides
these two, a fill is any function `fn(rng, rows)` that returns a value for
every row of the table, or a SciPy distribution, such as
`scipy.stats.lognorm(0.4, scale=11_000)`. Only blank values take the fill;
reported values stay as reported.

::

from relativities import Study, fill

study = Study(
book,
fill=\{
"vehicles.annual\_mileage": fill.like("garaging\_state"),
"drivers.credit\_tier": fill.shares(\{"good": 0.6, "fair": 0.3, "poor": 0.1}),
},
draws=200,
seed=7,
)

## like

```python theme={null}
def like(*by: str) -> Any
```

Borrow each blank value from a random row with the same `by` values.

`fill.like("garaging_state", "vehicle_year")` fills a blank annual
mileage from a vehicle in the same state and year that reports one. When
that group is empty, it matches on fewer columns, dropping the last first,
and then on the whole table. `by` names columns of the table it fills.
For a set of columns filled together, one donor gives all of them.

## shares

```python theme={null}
def shares(weights: Mapping[Any, float]) -> Any
```

Pick each blank value at random, in the given shares.

`fill.shares({"good": 0.6, "fair": 0.3, "poor": 0.1})` fills about 60% of
blanks with `"good"`. The weights are relative, so `{"a": 3, "b": 1}` is
75% and 25%. For a set of columns filled together, each value is a tuple
with one item per column.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.