a2rl.WiDataFrame.to_csv_dataset#

WiDataFrame.to_csv_dataset(path_or_buf, *args, forced_categories=None, compact=False, **kwargs)[source]#

Save this data frame as a Whatif dataset.

This method has similar signatures to pandas.DataFrame.to_csv(), however with some changes.

Parameters:
Return type:

None

See also

read_csv_dataset

Example

Save a WiDataFrame to directory /tmp/my-dataset.

>>> from a2rl import WiDataFrame
>>> df = WiDataFrame(
...     {
...         "i": [3, 4, 5],
...         "s": [1, 2, 3],
...         "j": [4, 5, 6],
...         "a": ["x", "y", "z"],
...         "k": ["z", "x", "y"],
...         "r": [0.5, 1.5, 2.5],
...     },
...     states=["s"],
...     actions=["a"],
...     rewards=["r"],
... )

>>> df
   i  s  j  a  k    r
0  3  1  4  x  z  0.5
1  4  2  5  y  x  1.5
2  5  3  6  z  y  2.5

>>> df.to_csv_dataset("/tmp/my-dataset")