{ "info": { "author": "Peter Graf", "author_email": "peter@pynto.tech", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "## pynto: Time series analysis in Python using the concatenative paradigm\n\npynto is a Python package that lets you manipulate tabular data with the expressiveness and code reusability of [concatenative](https://en.wikipedia.org/wiki/Concatenative_programming_language) programming. With pynto you define an _expression_ that formally specifies how to calculate the data in your table. Expressions are made by chaining together functions called _words_. It works like a pipeline: the output from one word becomes the input for the following word. The table of data is treated like a stack of independent columns. The rightmost column in the table is the top of the stack. Words can add, remove or modify columns, but they are row-agnostic--expressions can be evaluated over any range of rows. \n## What does it look like?\n```\n>>> import pynto as pt \n>>> ma_dev = pt.saved('stock_prices') \\ # define an expression that appends columns from the build-in database\n>>> .quote(pt.dup.rolling(20).mean.sub) \\ # append a quoted expression to the stack\n>>> .each # use the each combinator to apply the quotation to the previous columns\n>>> df = ma_dev['2021-06-01':] # evaluate your expression over a date range to get a DataFrame\n>>> pt.db['stocks_ma_dev'] = df # save the results back to the database \n```\n\n## Why pynto?\n - Expressive: Pythonic syntax; Combinatory logic for modular, reusable code \n - Performant: Column-wise multiprocessing; caching of duplicate operations\n - Batteries included: Built-in Redis-based time series database\n - Interoperable: Seemlessly integration with Pandas\n\n## Get pynto\n```\npip install pynto\n```\n## Reference\n\n### The Basics\n\nCreate expressions by chaining built-in words together using a fluent interface, or using the `+` operator for words in the local namespace. When evaluated, words will operate in left-to-right order, with operators following their operands in _postfix_ style. \n```\n>>> square = pt.dup.mul # duplicates the top column, then multiplies top two columns together\n```\nThe word `c` that adds a constant-value column to the stack. Like many pynto words, `c` takes a _parameter_ in parentheses to specify the constant value `c(10.0)`. pynto can handle any NumPy data type, but all rows in a column have to have the same type.\n\n```\n>>> expr = pt.c(10.0) + square # compose square expression with a columns of 10s\n```\nTo evaluate your expression, specify a date range using the `[`_start_`:`_stop (exclusive)_`:`_periodicity_`]` syntax. (Instances of `pt.Range` in the local namespace also work.)\n```\n>>> expr['2021-06-01':'2021-06-03','B'] # evaluate over a two business day date range \n constant\n2021-06-01 100.0\n2021-06-02 100.0\n```\nEach column has a string header that can be modified. `hset` sets the header to a new value. Headers can be usefully for filtering or arranging columns.\n```\n>>> expr += pt.hset('ten squared')\n>>> expr['2021-06-01':'2021-06-03','B'] \n ten squared\n2021-06-01 100.0\n2021-06-02 100.0\n```\n_Combinators_ are higher-order functions that allow pynto to do more complicated things like branching and looping. Combinators operate on _quotations_, expressions that are pushed to the stack instead of operating on the stack. To create a quotation put an expression within the parentheses of `pt.quote()`.\n```\n>>> expr = pt.c(9.).c(10.).quote(square).each\n>>> expr['2021-06-01':'2021-06-02']\n constant constant\n2021-06-01 81.0 100.0\n```\n\n### The Database\n\npynto has built-in time series database functionality that lets you save pandas DataFrames and Series to a Redis database. The database uses only String key/values, saving the underlying numpy data in native byte format for zero-copy retrieval. Each DataFrame column is saved as an independent key and can be retrieved on its own. The database also supports three-dimensional frames that have a two-level MultiIndex. Saved data can be accessed through pynto expressions or standard methods\n\n```\n>>> pt.db['my_df'] = expr['2021-06-01':'2021-06-03']\n>>> pt.saved('my_df')['2021-06-01':'2021-06-02']\n constant constant\n2021-06-01 81.0 100.0\n>>> pt.db.read('my_df')\n constant constant\n2021-06-01 81.0 100.0\n2021-06-02 81.0 100.0\n```\n\n## pynto built-in vocabulary\n\n### Words for adding columns\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\nc|value| -- c|Adds a constant-_value_ column.\ncsv|csv_file, index_col=0, header='infer'| -- c (c)|Adds columns from _csv_file_.\npandas|frame_or_series| -- c (c)|Adds columns from a pandas data structure.\nc_range|value| -- c (c)|Add constant int columns from 0 to _value_.\n\n### Combinators\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\ncall|depth=None, copy=False| a q -- c| Apply quotation to stack, up to _depth_ if specified. Optionally leaves stack in place with _copy_.\neach|start=0, stop=None, every=1, copy=False| a b q -- c d| Apply quotation stack elements from _start_ to _end_ in groups of _every_. Optionally leaves stack in place with _copy_.\nrepeat|times| a b q -- c d| Apply quotation to the stack _times_ times.\ncleave|num_quotations, depth=None, copy=False| a q q -- c d| Apply _num_quotations_ quotations to copies of stack elements up to _depth_. Optionally leaves stack in place with _copy_.\n\n### Words to manipulate columns\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\ndup|| a -- a a| Duplicate top column.\nroll|| a b c -- c a b| Permute columns.\nswap|| a b -- b a| Swap top two columns.\ndrop|| a b c -- a b| Drop top column.\nclear|| a b c -- | Clear columns.\ninterleave|count=None, split_into=2|a b c d -- a c b d|Divide columns into _split into_ groups and interleave group elements.\npull|start,end=None,clear=False|a b c -- b c a|Bring columns _start_ (to _end_) to the top.\nhpull|\\*headers, clear=False|a b c -- b c a|Bring columns with headers matching regex _headers_ to the top. Optionally clear remainder of stack\nhfilter|\\*headers, clear=False|a b c -- a|Shortcut for hpull with _clear_=True\n\n### Words to manipulate headers\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\nhset|\\*headers| a b -- a b|Set top columns' headers to _headers_.\nhformat|format_string| a -- a|Apply _format_string_ to existing headers.\nhapply|header_function| a -- a|Apply _header_function_ to existing header.\n\n### Words for arithmetic or logical operators\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\nadd||a b -- c|a + b\nsub||a b -- c|a - b\nmul||a b -- c|a * b\ndiv||a b -- c|a / b\nmod||a b -- c|a % b\npow||a b -- c|a ** b\neq||a b -- c|a == b\nne||a b -- c|a != b\nge||a b -- c|a >= b\ngt||a b -- c|a > b\nle||a b -- c|a <= b\nlt||a b -- c|a < b\nneg||a -- c|a * -1\nabs||a -- c|abs(a)\nsqrt||a -- c|a ** 0.5\nzeroToNa|| a -- c|Replaces zeros with np.nan\n\n### Words for creating window columns\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\nrolling|window=2, exclude_nans=True, lookback_multiplier=2|a -- w|Create window column with values from most recent _window_ rows. Exclude nan-valued rows from count unless _exclude_nans_. Extend history up to _lookback_multiplier_ to look for non-nan rows. \ncrossing||a b c -- w|Create window column with cross-sectional values from the same rows of all columns. \n\n### Words for calculating statistics on window columns\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\nsum||w -- c|Sums of windows.\nmean||w -- c|Means of windows.\nvar||w -- c|Variances of windows.\nstd||w -- c|Standard deviations of windows.\nchange||w -- c|Changes between first and last rows of windows.\npct_change||w -- c|Percent changes between first and last rows of windows.\nlog_change||w -- c|Differences of logs of first and last rows of windows.\nfirst||w -- c|First rows of windows.\nlast||w -- c|Last rows of windows.\nzscore||w -- c|Z-score of most recent rows within windows.\n\n### Words for cleaning up data\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\nfill|value|a -- a|Fill nans with _value_.\nffill||a -- a|Last observation carry-forward.\njoin|date|a b -- c|Join top two columns, switching from second to first on _date_ index.\n\n### Other words\nName | Parameters |Stack effect
_before_ -- _after_|Description\n:---|:---|:---|:---\newma|window, fill_nans=True|a -- c|Calculates exponentially-weighted moving average with half-life _window_. \nwlag|number|w -- c|Lag _number_ rows.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/punkbrwstr/pynto", "keywords": "data analysis quantitative tabular concatenative functional", "license": "", "maintainer": "", "maintainer_email": "", "name": "pynto", "package_url": "https://pypi.org/project/pynto/", "platform": "", "project_url": "https://pypi.org/project/pynto/", "project_urls": { "Homepage": "https://github.com/punkbrwstr/pynto" }, "release_url": "https://pypi.org/project/pynto/0.3/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Data analysis using a concatenative paradigm", "version": "0.3", "yanked": false, "yanked_reason": null }, "last_serial": 11134720, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "8e912513a0ed4647f88f2a1d6a56c9ff", "sha256": "161778be9f9a35b0270c52fdf9678c6ad3b86e605a9cd83e54d5ec91b2f4289b" }, "downloads": -1, "filename": "pynto-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8e912513a0ed4647f88f2a1d6a56c9ff", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 12641, "upload_time": "2019-10-24T19:01:28", "upload_time_iso_8601": "2019-10-24T19:01:28.668026Z", "url": "https://files.pythonhosted.org/packages/8f/ba/6397d07c376246ed654ed91629011f99441d45f34761dd736c87c1c6b757/pynto-0.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3be486dea91523d764628a6176c2b1cb", "sha256": "f6effe5a47309f3214db6f5a2cb6a39cafb581d017ce7e13956a157d4fd7cac3" }, "downloads": -1, "filename": "pynto-0.1.tar.gz", "has_sig": false, "md5_digest": "3be486dea91523d764628a6176c2b1cb", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15364, "upload_time": "2019-10-24T19:01:31", "upload_time_iso_8601": "2019-10-24T19:01:31.166298Z", "url": "https://files.pythonhosted.org/packages/83/f5/361a634845148e4757928a3d5c8b1feaadbb637f4e19a876e85ace7f094f/pynto-0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "46093dfba7ecf9f1a86dcf067bc8a85f", "sha256": "f2965ed6bf28153024bb5c57efdb0bb69e42c7ef7f24b93066befd9901dd71d5" }, "downloads": -1, "filename": "pynto-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "46093dfba7ecf9f1a86dcf067bc8a85f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 12662, "upload_time": "2019-10-24T19:12:10", "upload_time_iso_8601": "2019-10-24T19:12:10.892582Z", "url": "https://files.pythonhosted.org/packages/9e/2a/75341e378f0db2d89e4f0d22f87e3468aaeda484b3cb8e9930e21fbb76f7/pynto-0.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "6ae0aa313da4dcde341786ea4d10fe24", "sha256": "4729cb86246ca4d72057f63173e5e214fa8b40105438eb27fd20c5ee25515d48" }, "downloads": -1, "filename": "pynto-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6ae0aa313da4dcde341786ea4d10fe24", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15373, "upload_time": "2019-10-24T19:12:13", "upload_time_iso_8601": "2019-10-24T19:12:13.219391Z", "url": "https://files.pythonhosted.org/packages/a2/16/28007bcd71f86ab543f1f44f4df6fb7a4eeba0f93d0625b81688b958ad2d/pynto-0.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "b53f3d32a60c605dd86d42287a699b5d", "sha256": "48d4e8017517af175d9a98057f88711e8661a5c6235b65f9581ae21cd4c2dd5d" }, "downloads": -1, "filename": "pynto-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b53f3d32a60c605dd86d42287a699b5d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 12902, "upload_time": "2019-11-19T07:37:43", "upload_time_iso_8601": "2019-11-19T07:37:43.465100Z", "url": "https://files.pythonhosted.org/packages/58/c7/869da30f154f799d2620e57da5593be2b43abd8c377a00b7640a97fafa36/pynto-0.1.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a69ff7c51ca0e7e48af9ecae731ce6c3", "sha256": "c8411644d363b84f62ecdbb229130021fb552763da3aece6cc0ee137a664cfb3" }, "downloads": -1, "filename": "pynto-0.1.2.tar.gz", "has_sig": false, "md5_digest": "a69ff7c51ca0e7e48af9ecae731ce6c3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15603, "upload_time": "2019-11-19T07:37:44", "upload_time_iso_8601": "2019-11-19T07:37:44.531852Z", "url": "https://files.pythonhosted.org/packages/1d/ea/f0227dd5b12d771c4dab04bb68c115ddf808275637810f0a8f85591c894c/pynto-0.1.2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2": [ { "comment_text": "", "digests": { "md5": "4e6f548b1a66c176f24b9a814bca150d", "sha256": "8976c1a59b452a3af425834c0868ea9adf322092aff871da37ab3f4b7d17d2e5" }, "downloads": -1, "filename": "pynto-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "4e6f548b1a66c176f24b9a814bca150d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 15221, "upload_time": "2020-11-19T22:12:38", "upload_time_iso_8601": "2020-11-19T22:12:38.152076Z", "url": "https://files.pythonhosted.org/packages/df/e4/b2674ee2d6cf62c41c0e2bea624bfc2bc08ab70603506013f386653313d9/pynto-0.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "d93cd10b1fb111ceadc79d97ddf18acf", "sha256": "8e900158a2a3b1af82476e9654888d32c9b7b019d2e34147aa1d5ce03a12d3a9" }, "downloads": -1, "filename": "pynto-0.2.tar.gz", "has_sig": false, "md5_digest": "d93cd10b1fb111ceadc79d97ddf18acf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 18210, "upload_time": "2020-11-19T22:12:39", "upload_time_iso_8601": "2020-11-19T22:12:39.092934Z", "url": "https://files.pythonhosted.org/packages/91/b2/5982511c88f0f41097c9fcceb8fc3be124fcda0cbdfd6ff355c5550564f3/pynto-0.2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.3": [ { "comment_text": "", "digests": { "md5": "23eca33be0f09165ff8b899d32c4bfe6", "sha256": "a8d95b4f074602af1ba78c5cc2ae8175125ae8d1ad2be78ecf5c73358d0fdcd0" }, "downloads": -1, "filename": "pynto-0.3.tar.gz", "has_sig": false, "md5_digest": "23eca33be0f09165ff8b899d32c4bfe6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 23853, "upload_time": "2021-08-09T23:24:58", "upload_time_iso_8601": "2021-08-09T23:24:58.046792Z", "url": "https://files.pythonhosted.org/packages/4c/87/d27be9dc739aaaaff791ba3d11f538f86f64d102d7347d7f7387ec3eba4b/pynto-0.3.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "23eca33be0f09165ff8b899d32c4bfe6", "sha256": "a8d95b4f074602af1ba78c5cc2ae8175125ae8d1ad2be78ecf5c73358d0fdcd0" }, "downloads": -1, "filename": "pynto-0.3.tar.gz", "has_sig": false, "md5_digest": "23eca33be0f09165ff8b899d32c4bfe6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 23853, "upload_time": "2021-08-09T23:24:58", "upload_time_iso_8601": "2021-08-09T23:24:58.046792Z", "url": "https://files.pythonhosted.org/packages/4c/87/d27be9dc739aaaaff791ba3d11f538f86f64d102d7347d7f7387ec3eba4b/pynto-0.3.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }