save_output

save_output(x, path=None, **kwargs)

Quick-save any ezrsurvey output (plot or table).

Convenience dispatcher: routes plotnine charts to save_plot() and data frames / dicts of them to save_data(), choosing by the object type. Handy at the end of a pipe when you do not want to think about which saver to call.

Parameters

Name Type Description Default
x plotnine.ggplot, pandas.DataFrame or dict of DataFrame What to save. required
path str Output path; the extension picks the format. None (default) writes plot.png or data.csv. A bare file name lands in ezrsurvey-outputs/ (created on demand); a path naming a directory (“./x.png”, “charts/x.png”, anything absolute) is used exactly as given. See the output_dir option. None
**kwargs Passed to save_plot() or save_data(). {}

Returns

Name Type Description
object x.

See Also

save_plot, save_data

Examples

>>> import tempfile, os
>>> tmp_csv = os.path.join(tempfile.mkdtemp(), "table.csv")
>>> calc_percentage(podracing_survey, "demo_gender").pipe(save_output, tmp_csv)