vivainsights.export

Display and export data frames and plot objects to various formats.

Functions: - display_plot: Universal function to display plots regardless of type (matplotlib.Figure or seaborn.FacetGrid) - export: Exports data frames or plot objects using the specified method/format

By default, export() copies a data frame to the clipboard, and matplotlib objects are saved as PNG files.

vivainsights.export.display_plot(plot_obj)[source]

Universal function to display plots regardless of type.

Handles both matplotlib.figure.Figure objects (from create_bar, create_trend, etc.) and seaborn.axisgrid.FacetGrid objects (from create_line with >4 groups).

Parameters:

plot_obj (matplotlib.figure.Figure or seaborn.axisgrid.FacetGrid) – The plot object to display

Returns:

Displays the plot using the appropriate method

Return type:

None

Examples

>>> import vivainsights as vi
>>> plot = vi.create_line(data=vi.load_pq_data(), metric='Email_hours', hrvar='Organization')
>>> vi.display_plot(plot)
vivainsights.export.export(x, file_format='auto', path='insights export', dpi=300, timestamp=True)[source]

Export data frames or plot objects to various formats.

A general-purpose function to export vivainsights outputs to CSV, clipboard, or save as images. By default, copies a DataFrame to the clipboard and displays plot objects.

Parameters:
  • x (pandas.DataFrame or matplotlib.figure.Figure) – Object to export.

  • file_format (str, optional) – Export method. Defaults to "auto" which copies DataFrames to clipboard and displays plot objects. Other options: "csv", "png", "svg", "jpeg", "pdf", "clipboard", "display".

  • path (str, optional) – File path (without extension). Defaults to "insights export".

  • dpi (int, optional) – Dots per inch for image export. Defaults to 300.

  • timestamp (bool, optional) – Whether to append a timestamp to the file name. Defaults to True.

Returns:

Output is written to disk, clipboard, or displayed depending on file_format.

Return type:

None

Examples

>>> import vivainsights as vi
>>> # Auto behavior — plot will be displayed
>>> km_plot = vi.keymetrics_scan(data=vi.load_pq_data(), hrvar='Organization', return_type="plot")
>>> vi.export(km_plot)
>>>
>>> # Auto behavior — DataFrame will be copied to clipboard
>>> data = vi.load_pq_data()
>>> vi.export(data)
>>>
>>> # Explicit file export
>>> vi.export(km_plot, file_format='png', path='keymetrics_scan', timestamp=False)