Package: xplorts
Explore time series datasetsxplorts("explore-tee-ess") is a collection of Python tools to make standalone HTML documents containing interactive charts.  It is particularly aimed at showing time series data (hence the "ts") with annual, quarterly or monthly periodicity, such as that published by national statistical institutes by way of national accounts, productivity, or labour markets series.Once created, the HTML documents can be used with any web browser.  They do not need an
active internet connection.Installationpip install xplortsForxplorts.utils.ukons_lprod_to_csvetc., you also needopenpyxl:pip install openpyxlDemoTo see an interactive sample data explorer, tryExplore UK output per hour worked.Source: Office for National Statistics licensed under the Open Government Licence v.3.0Steps to make explorer for ONS labour productivity dataDownloadOutput per hour worked, UKfrom the ONS web site.Open aTerminalwindow (Macintosh) orCommand promptwindow (Windows).Extract productivity, gross value added and labour data using the utility scriptukons_lprod_to_csv.py.  The extracted time series will go into a fileoutputperhourworked.csvin the folder next to the originalExceldataset.In the command shell or terminal window:python xplorts/utils/ukons_lprod_to_csv.py outputperhourworked.xlsx --quarterly --sectionNote: For older versions of Pandas you will have to open the Excel file, save it as.xls, and use that rather than the original.xlsxformat.Run the moduledblprodto create a stand-aloneHTMLlabour productivity dashboard in the fileoutputperhourworked.html.In the command shell or terminal window:python -m xplorts.dblprod outputperhourworked.csv -d date -b industry -p lprod -g gva -l labourUse the explorer in any web browser.FeaturesThe labour productivity explorer demonstrates these features:A grouped multi-line chart shows a set of related lines for one split level at a time, like time series for productivity, gross value added, and hours worked for a particular industry.A time series components chart shows a set of stacked bars in combination with a totals line, for one split level at a time, like cumulative growth time series for gross value added, hours worked (sign reversed), and productivity for a particular industry.A snapshot growth components chart shows a set of stacked bars in combination with markers showing total growth, as a function of a categorical factor, like growth for gross value added and hours worked (sign reversed) by industry, along with growth in productivity, for a selectable time period.A heatmap chart shows data values as a function of a categorical split variable across time.Drop-down list and slider widgets provide interactive selection of a categorical split level or snapshot time period to show. Static screenshots are shown here, but check out the interactive sample data explorer at the link above.Hover tool displays data values at the cursor location.Chart tools include box zoom, wheel zoom, pan, and save to file.Time periods can be represented on a chart axis as nested categories like (year, quarter).A categorical chart axis can represent time periods or levels of a split factor.Usingxplortsin PythonImportImport the package into your code:import xplortsPackage documentationTo show the docstring for the package:xplorts?To show the docstring for a particular module, likeslideselect:xplorts.slideselect?ModulesModuleDescriptionbaseMiscellaneous helper functions and classes.diffMulti-tab revisions display for two vintages of a dataset.dutilsMiscellaneous data manipulation helpers.dashboardMulti-tab dashboard showing levels, growth components, and growth heatmaps.dblprodModify a Bokeh Figure by adding charts to show labour productivity levels or growth components.ghostbokehDefine an abstract base class to a build pseudo-subclass of a Bokeh class.growthcompsGrowth of time series and their contribution to growth of derived series.heatmapFunctions to create a heatmap of data values as a function of horizontal and vertical categorical variables.linesLine charts to show several time series with a split factor.scatterScatter charts to show one or more categorical series with a split factor.slideselectClass combining select and slider widgets, with support for javascript linking to other objects.snapcompSnapshot growth components chart, with a categorical vertical axis showing levels of a split factor, horizontal stacked bars showing growth components, and markers showing overall growth for each stack of bars.stacksHorizontal or vertical stacked bar chart showing several data series with a split factor.tscompGrowth components chart, with a categorical vertical axis showing levels of a split factor, horizontal  stacked bars showing growth components, and a line showing overall growth.Usingxplortson the command lineInstall (once, possibly within a particular virtual environment)Open aTerminalwindow (Macintosh) orCommand promptwindow (Windows)Activate virtual environment, if relevantOn Windows:activate my_envOn Mac:conda activate my_envExecute anxplortsmodule entry pointxp-dashboard ...Or tellpythonexplicitly to run anxplortsmodulepython -m xplorts.dashboard ...Getting help about command line optionsPass the option-hto anyxplortsscript to get help.  For example:xp-dashboard -hOrpython -m xplorts.dblprod -husage: dblprod.py [-h] [-b BY] [-d DATE] [-p LPROD] [-v GVA] [-l LABOUR]
                      [-g ARGS] [-t SAVE] [-s]
                      datafile

Create interactive visualiser for labour productivity levels with a split
factor

positional arguments:
  datafile              File (CSV) with data series and split factor

optional arguments:
  -h, --help            Show this help message and exit
  -b BY, --by BY        Factor variable for splits
  -d DATE, --date DATE  Date variable
  -p LPROD, --lprod LPROD
                        Productivity variable
  -v GVA, --gva GVA     Gross value added (GVA) variable
  -l LABOUR, --labour LABOUR
                        Labour variable (e.g. jobs or hours worked)
  -g ARGS, --args ARGS  Keyword arguments.  YAML mapping of mappings.  The
                        keys 'lines', 'growth_series' and 'growth_snapshot'
                        can provide keyword arguments to pass to
                        `prod_ts_lines`, `prod_ts_growth` and
                        `prod_growth_snapshot`, respectively.
  -t SAVE, --save SAVE  Interactive .html to save, if different from the
                        datafile base
  -s, --show            Show interactive .htmlxplortsscriptsScriptEntry pointDescriptiondashboardxp-dashboardMulti-tab dashboard showing levels, growth components, and growth heatmaps.dblprodxp-dblprodCreate a labour productivity dashboard, with three charts including:a lines chart showing levels of labour productivity, gross value added, and labour,a time series growth components chart showing cumulative growth in labour productivity, gross value added, and labour, anda snapshot growth components chart showing period-on-period growth in labour productivity, gross value added, and labour.diffxp-diff Multi-tab revisions display for two vintages of a dataset, showing revisions in levels, growths, and cumulative growth.heatmapxp-heatmapCreate a heatmap of values as a function of two categorical variables.linesxp-linesCreate a line chart showing several time series with a split factor.  Widgets select one split factor category at a time.scatterxp-scatterCreate scatter chart showing one or more time series with a split factor.  Widgets select one split factor category at a time.snapcompxp-snapcompCreate a snapshot growth components chart, with a categorical vertical axis showing levels of a split factor, horizontal stacked bars showing growth components, and a line showing overall growth.  A widget selects one time period at a time.stacksxp-stacksCreate stacked bar chart showing several data series with a split factor.  Widgets select one split factor at a time (or one time period at a time if the split factor is plotted as a chart axis).tscompxp-tscompCreate a time series growth components chart, with time periods along the horizontal axis, vertical stacked bars showing growth components, and a line showing overall growth.  Widgets select one split factor category at a time.utils.ukons_lcli_to_csvExtract data from ONSlabour costs and labour income dataset, in a format suitable for use withxplortscharts.utils.ukons_lprod_to_csvExtract data from ONS labour productivity datasets such asOutput per hour worked, UK, in a format suitable for use withxplortscharts.utils.ukons_psp_to_csvExtract data from ONS datasetPublic service productivity estimates: total public service, in a format suitable for use withxplortscharts.