Skip to main content

A data analysis package based on modelling and manipulation of mathematical step functions. Strongly aligned with pandas.

Project description

staircase logo

The leading use-case for the staircase package is for the creation and analysis of step functions.

Pretty exciting huh.

But don't hit the close button on the browser just yet. Let us convince you that much of the world around you can be modelled as step functions.

For example, the number of users viewing this page over time can be modelled as a step function. The value of the function increases by 1 every time a user arrives at the page, and decreases by 1 every time a user leaves the page. Let's say we have this data in vector format (i.e. tuple, list, numpy array, pandas series). Specifically, assume arrive and leave are vectors of times, expressed as minutes past midnight, for all page views occuring yesterday. Creating the corresponding step function is simple. To achieve it we use the Stairs class:

>>> import staircase as sc

>>> views = sc.Stairs()
>>> views.layer(arrive,leave)

We can visualise the function with the plot function:

>>> views.plot()

pageviews example

We can find the total time in minutes the page was viewed:

>>> views.clip(0,1440).integral()
9297.94622521079

We can find the average number of viewers:

>>> views.clip(0,1440).mean()
6.4569071008408265

We can find the average number of viewers, per hour of the day, and plot:

>>> views.slice(pd.interval_range(0, periods=24, freq=60)).mean().plot()

mean page views per hour

We can find the maximum concurrent views:

>>> views.clip(0,1440).max()
16

We can create histogram data showing relative frequency of concurrent viewers (and plot it):

>>> views.clip(0,1440).hist().plot.bar()

concurrent viewers histogram

Plotting is based on matplotlib and it requires relatively little effort to take the previous chart and improve the aesthetics:

concurrent viewers histogram (aesthetic)

There is plenty more analysis that could be done. The staircase package provides a rich variety of arithmetic operations, relational operations, logical operations, statistical operations, for use with Stairs, in addition to functions for univariate analysis, aggregations and compatibility with pandas.Timestamp.

Installation

staircase can be installed from PyPI:

python -m pip install staircase

or also with conda:

conda install -c conda-forge staircase

Documentation

The complete guide to using staircase can be found at staircase.dev

Contributing

There are many ways in which contributions can be made - the first and foremost being using staircase and giving feedback.

Bug reports, feature requests and ideas can be submitted via the Github issue tracker.

Additionally, bug fixes. enhancements, and improvements to the code and documentation are also appreciated and can be done via pull requests. Take a look at the current issues and if there is one you would like to work on please leave a comment to that effect.

See this beginner's guide to contributing, or Pandas' guide to contributing, to learn more about the process.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

The seeds of staircase began developing at the Hunter Valley Coal Chain Coordinator, where it finds strong application in analysing simulated data. Thanks for the support!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

staircase-2.1.1.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

staircase-2.1.1-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file staircase-2.1.1.tar.gz.

File metadata

  • Download URL: staircase-2.1.1.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for staircase-2.1.1.tar.gz
Algorithm Hash digest
SHA256 bb8792fb64c0668724840395f5545f73ea15b388e9edb0afc66ff21b480470fe
MD5 104874e23ccf064fb544c69cef55851a
BLAKE2b-256 fd921745953a3955bacfe62bda3f9801642feaea6d778e18ce83ae488b526deb

See more details on using hashes here.

File details

Details for the file staircase-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: staircase-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 52.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for staircase-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a61122941c2af65087cbf35d3acb471615cf257b8249afaf0f97bf681eb4078d
MD5 7af544fce756e8506abf0dcf15bd2e27
BLAKE2b-256 5eeae2e9a784d38b096c76449698c3330a732b0caae4edb81fa59ab39dadc16d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page