plydata.options.options¶
-
class
plydata.options.
options
(**kwargs)[source]¶ Options context manager
The code in the context is run with the specified options. This is a convenient wrapper around
set_option()
to handle setting and unsetting of option values.- Parameters
- kwargs
dict
{option_name: option_value}
pairs.
- kwargs
Examples
>>> import pandas as pd >>> from plydata import define >>> from plydata.options import options >>> df = pd.DataFrame({'x': [0, 1, 2, 3]})
With the default options
>>> df2 = df >> define(y='2*x') >>> df2 x y 0 0 0 1 1 2 2 2 4 3 3 6 >>> df x 0 0 1 1 2 2 3 3
Using the context manager
>>> with options(modify_input_data=True): ... df3 = df >> define(z='3*x') >>> df3 x z 0 0 0 1 1 3 2 2 6 3 3 9 >>> df x z 0 0 0 1 1 3 2 2 6 3 3 9 >>> df is df3 True
The default options apply again.
>>> df4 = df >> define(w='4*x') >>> df x z 0 0 0 1 1 3 2 2 6 3 3 9 >>> df is df4 False