a2rl.WiSeries#

class a2rl.WiSeries(data=None, states=None, actions=None, rewards=None, **kwargs)[source]#

Bases: Series, SarMixin

A WiSeries object is a pandas.Series with additional metadata on the expected column names for states, actions, and rewards (i.e., the sar columns).

In addition to the standard pandas.Series constructor arguments, a WiSeries also accepts the following keyword arguments:

Parameters:

Warning

This class is mainly used internally by whatif.

By design, the name of a WiSeries is equal to zero or one expected sar column name.

Examples

Create a new WiSeries:

>>> import a2rl as wi
>>> ser = wi.WiSeries(
...     [11, 12, 13],
...     name="s0",
...     states=["s1", "s2"],
...     actions=["a"],
...     rewards=["r"],
... )

>>> ser
0    11
1    12
2    13
Name: s0, dtype: int64

>>> ser.sar
['s1', 's2', 'a', 'r']

Inherit sar columns from the source WiDataFrame:

>>> df = wi.WiDataFrame(
...     {
...         "s": [0, 1, 2],
...         "a": ["x", "y", "z"],
...         "r": [0.5, 1.5, 2.5],
...     },
...     states=["s"],
...     actions=["a"],
...     rewards=["r"],
... )
>>> ser = df['a']
>>> ser.sar
['s', 'a', 'r']

Methods

to_csv_dataset(path_or_buf, *args[, ...])

Save this series as a Whatif dataset.

Attributes

actions

The list of the expected column names of actions.

rewards

The list of the expected column names of rewards.

sar

The list of the expected sar column names.

sar_d

The dictionary of 585 expected sar column names.

states

The list of the expected column names of states.