{ "info": { "author": "Quantopian Inc.", "author_email": "opensource@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: C", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Scientific/Engineering" ], "description": "warp_prism\n==========\n\nQuickly move data from postgres to numpy or pandas.\n\nAPI\n---\n\n``to_arrays(query, *, bind=None)``\n``````````````````````````````````\n\n.. code-block::\n\n Run the query returning a the results as np.ndarrays.\n\n Parameters\n ----------\n query : sa.sql.Selectable\n The query to run. This can be a select or a table.\n bind : sa.Engine, optional\n The engine used to create the connection. If not provided\n ``query.bind`` will be used.\n\n Returns\n -------\n arrays : dict[str, (np.ndarray, np.ndarray)]\n A map from column name to the result arrays. The first array holds the\n values and the second array is a boolean mask for NULLs. The values\n where the mask is False are 0 interpreted by the type.\n\n\n``to_dataframe(query, *, bind=None, null_values=None)``\n```````````````````````````````````````````````````````\n\n.. code-block::\n\n Run the query returning a the results as a pd.DataFrame.\n\n Parameters\n ----------\n query : sa.sql.Selectable\n The query to run. This can be a select or a table.\n bind : sa.Engine, optional\n The engine used to create the connection. If not provided\n ``query.bind`` will be used.\n null_values : dict[str, any]\n The null values to use for each column. This falls back to\n ``warp_prism.null_values`` for columns that are not specified.\n\n Returns\n -------\n df : pd.DataFrame\n A pandas DataFrame holding the results of the query. The columns\n of the DataFrame will be named the same and be in the same order as the\n query.\n\n\n``register_odo_dataframe_edge()``\n`````````````````````````````````\n\n.. code-block::\n\n Register an odo edge for sqlalchemy selectable objects to dataframe.\n\n This edge will have a lower cost that the default edge so it will be\n selected as the fasted path.\n\n If the selectable is not in a postgres database, it will fallback to the\n default odo edge.\n\n\nComparisons\n-----------\n\nA quick comparison between ``warp_prism``, ``odo``, and ``pd.read_sql_table``.\n\nIn this example we will read real data for VIX from quandl stored in a local\npostgres database using ``warp_prism``, ``odo``, and ``pd.read_sql_table``.\nAfter that, we will use ``odo`` to create a table with two float columns and\n1000000 rows and query it with the tree tools again.\n\n.. code-block:: python\n\n In [1]: import warp_prism\n\n In [2]: from odo import odo, resource\n\n In [3]: import pandas as pd\n\n In [4]: table = resource(\n ...: 'postgresql://localhost/bz::yahoo_index_vix',\n ...: schema='quandl',\n ...: )\n\n In [5]: warp_prism.to_dataframe(table).head()\n Out[5]:\n asof_date open_ high low close volume \\\n 0 2016-01-08 22.959999 27.080000 22.480000 27.010000 0.0\n 1 2015-12-04 17.430000 17.650000 14.690000 14.810000 0.0\n 2 2015-10-29 14.800000 15.460000 14.330000 14.610000 0.0\n 3 2015-12-21 19.639999 20.209999 18.700001 18.700001 0.0\n 4 2015-10-26 14.760000 15.430000 14.680000 15.290000 0.0\n\n adjusted_close timestamp\n 0 27.010000 2016-01-11 23:14:54.682220\n 1 14.810000 2016-01-11 23:14:54.682220\n 2 14.610000 2016-01-11 23:14:54.682220\n 3 18.700001 2016-01-11 23:14:54.682220\n 4 15.290000 2016-01-11 23:14:54.682220\n\n In [6]: odo(table, pd.DataFrame).head()\n Out[6]:\n asof_date open_ high low close volume \\\n 0 2016-01-08 22.959999 27.080000 22.480000 27.010000 0.0\n 1 2015-12-04 17.430000 17.650000 14.690000 14.810000 0.0\n 2 2015-10-29 14.800000 15.460000 14.330000 14.610000 0.0\n 3 2015-12-21 19.639999 20.209999 18.700001 18.700001 0.0\n 4 2015-10-26 14.760000 15.430000 14.680000 15.290000 0.0\n\n adjusted_close timestamp\n 0 27.010000 2016-01-11 23:14:54.682220\n 1 14.810000 2016-01-11 23:14:54.682220\n 2 14.610000 2016-01-11 23:14:54.682220\n 3 18.700001 2016-01-11 23:14:54.682220\n 4 15.290000 2016-01-11 23:14:54.682220\n\n In [7]: pd.read_sql_table(table.name, table.bind, table.schema).head()\n Out[7]:\n asof_date open_ high low close volume \\\n 0 2016-01-08 22.959999 27.080000 22.480000 27.010000 0.0\n 1 2015-12-04 17.430000 17.650000 14.690000 14.810000 0.0\n 2 2015-10-29 14.800000 15.460000 14.330000 14.610000 0.0\n 3 2015-12-21 19.639999 20.209999 18.700001 18.700001 0.0\n 4 2015-10-26 14.760000 15.430000 14.680000 15.290000 0.0\n\n adjusted_close timestamp\n 0 27.010000 2016-01-11 23:14:54.682220\n 1 14.810000 2016-01-11 23:14:54.682220\n 2 14.610000 2016-01-11 23:14:54.682220\n 3 18.700001 2016-01-11 23:14:54.682220\n 4 15.290000 2016-01-11 23:14:54.682220\n\n In [8]: len(warp_prism.to_dataframe(table))\n Out[8]: 6565\n\n In [9]: %timeit warp_prism.to_dataframe(table)\n 100 loops, best of 3: 7.55 ms per loop\n\n In [10]: %timeit odo(table, pd.DataFrame)\n 10 loops, best of 3: 49.9 ms per loop\n\n In [11]: %timeit pd.read_sql_table(table.name, table.bind, table.schema)\n 10 loops, best of 3: 61.8 ms per loop\n\n In [12]: big_table = odo(\n ...: pd.DataFrame({\n ...: 'a': np.random.rand(1000000),\n ...: 'b': np.random.rand(1000000)},\n ...: ),\n ...: 'postgresql://localhost/test::largefloattest',\n ...: )\n\n In [13]: %timeit warp_prism.to_dataframe(big_table)\n 1 loop, best of 3: 248 ms per loop\n\n In [14]: %timeit odo(big_table, pd.DataFrame)\n 1 loop, best of 3: 1.51 s per loop\n\n In [15]: %timeit pd.read_sql_table(big_table.name, big_table.bind)\n 1 loop, best of 3: 1.9 s per loop\n\n\nInstallation\n------------\n\nWarp Prism can be pip installed but requires numpy to build its C extensions:\n\n.. code-block::\n\n $ pip install numpy\n $ pip install warp_prism\n\n\nLicense\n-------\n\nWarp Prism is licensed under the Apache 2.0.\n\nWarp Prism is sponsored by `Quantopian `_ where it\nis used to fetch data for use in `Zipline `_ through the\n`Pipeline API `_ or interactively\nwith `Blaze `_.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/quantopian/warp_prism", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "warp_prism", "package_url": "https://pypi.org/project/warp_prism/", "platform": "", "project_url": "https://pypi.org/project/warp_prism/", "project_urls": { "Homepage": "https://github.com/quantopian/warp_prism" }, "release_url": "https://pypi.org/project/warp_prism/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Quickly move data from postgres to numpy or pandas.", "version": "0.1.1" }, "last_serial": 2679263, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "1b4953a6fd825e7b5f8b82a52cd97db5", "sha256": "68844c6b94533e09973ad180b2970d1b1abf15a355165404bb558a259b5a88d7" }, "downloads": -1, "filename": "warp_prism-0.1.0.tar.gz", "has_sig": false, "md5_digest": "1b4953a6fd825e7b5f8b82a52cd97db5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11346, "upload_time": "2017-03-02T22:59:58", "url": "https://files.pythonhosted.org/packages/be/92/e47434c334a9afea0dd2dae81348a4f57ffc5ef6bb5336cd96378bfe5e73/warp_prism-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "fdf6efdebf4019c21e135588539d460f", "sha256": "d57df5dbadf1d2764de27e2e3edb339cb296cbf1be71c5b9c9d317d5ca5d598c" }, "downloads": -1, "filename": "warp_prism-0.1.1.tar.gz", "has_sig": false, "md5_digest": "fdf6efdebf4019c21e135588539d460f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11403, "upload_time": "2017-03-02T23:05:51", "url": "https://files.pythonhosted.org/packages/61/ef/d40839723444d99ac54dc207ce130b2ca96d66c7dfda91a650fe48a0da3e/warp_prism-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fdf6efdebf4019c21e135588539d460f", "sha256": "d57df5dbadf1d2764de27e2e3edb339cb296cbf1be71c5b9c9d317d5ca5d598c" }, "downloads": -1, "filename": "warp_prism-0.1.1.tar.gz", "has_sig": false, "md5_digest": "fdf6efdebf4019c21e135588539d460f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11403, "upload_time": "2017-03-02T23:05:51", "url": "https://files.pythonhosted.org/packages/61/ef/d40839723444d99ac54dc207ce130b2ca96d66c7dfda91a650fe48a0da3e/warp_prism-0.1.1.tar.gz" } ] }