{ "info": { "author": "Doist Team", "author_email": "dev@doist.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "\n![bitmapist](https://raw.githubusercontent.com/Doist/bitmapist4/master/static/bitmapist.png \"bitmapist\")\n\n\n[![Build Status](https://travis-ci.org/Doist/bitmapist4.svg?branch=master)](https://travis-ci.org/Doist/bitmapist4)\n\n**NEW!** Try out our new standalone [bitmapist-server](https://github.com/Doist/bitmapist-server), which improves memory efficiency 443 times and makes your setup cheaper and more scaleable. It's fully compatable with bitmapist that runs on Redis.\n\n# bitmapist: a powerful analytics library for Redis\n\nThis Python library makes it possible to implement real-time, highly scalable analytics that can answer following questions:\n\n* Has user 123 been online today? This week? This month?\n* Has user 123 performed action \"X\"?\n* How many users have been active have this month? This hour?\n* How many unique users have performed action \"X\" this week?\n* How many % of users that were active last week are still active?\n* How many % of users that were active last month are still active this month?\n* What users performed action \"X\"?\n\nThis library is very easy to use and enables you to create your own reports easily.\n\nUsing Redis bitmaps you can store events for millions of users in a very little amount of memory (megabytes).\nYou should be careful about using huge ids as this could require larger amounts of memory. Ids should be in range [0, 2^32).\n\nAdditionally bitmapist can generate cohort graphs that can do following:\n* Cohort over user retention\n* How many % of users that were active last [days, weeks, months] are still active?\n* How many % of users that performed action X also performed action Y (and this over time)\n* And a lot of other things!\n\nIf you want to read more about bitmaps please read following:\n\n* http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/\n* http://redis.io/commands/setbit\n* http://en.wikipedia.org/wiki/Bit_array\n* http://www.slideshare.net/crashlytics/crashlytics-on-redis-analytics\n\n\n\n# Installation\n\nCan be installed very easily via:\n\n $ pip install bitmapist4\n\n\n# Ports\n\n* PHP port: https://github.com/jeremyFreeAgent/Bitter\n\n\n# Examples\n\nSetting things up:\n\n```python\nimport bitmapist4\nb = bitmapist4.Bitmapist()\n```\n\nMark user 123 as active and has played a song:\n\n```python\nb.mark_event('active', 123)\nb.mark_event('song:played', 123)\n```\n\nAnswer if user 123 has been active this month:\n\n```python\nassert 123 in b.MonthEvents('active')\nassert 123 in b.MonthEvents('song:played')\n```\n\n\nHow many users have been active this week?:\n\n```python\nlen(b.WeekEvents('active'))\n```\n\nIterate over all users active this week:\n\n```python\nfor uid in b.WeekEvents('active'):\n print(uid)\n```\n\n\nTo explore any specific day, week, month or year instead of the current one, \nuou can create an event from any datetime object with a `from_date` static\nmethod.\n\n```python\nspecific_date = datetime.datetime(2018, 1, 1)\nev = b.MonthEvents('active').from_date(specific_date)\nprint(len(ev))\n```\n\nThere are methods `prev` and `next` returning \"sibling\" events and\nallowing you to walk through events in time without any sophisticated\niterators. A `delta` method allows you to jump forward or backward for\nmore than one step. Uniform API allows you to use all types of base events\n(from hour to year) with the same code.\n\n```python\n\ncurrent_month = b.MonthEvents('active')\nprev_month = current_month.prev()\nnext_month = current_month.next()\nyear_ago = current_month.delta(-12)\n```\n\nEvery event object has `period_start` and `period_end` methods to find a\ntime span of the event. This can be useful for caching values when the caching\nof \"events in future\" is not desirable:\n\n```python\n\nev = b.MonthEvent('active', dt)\nif ev.period_end() < datetime.datetime.utcnow():\n cache.set('active_users_<...>', len(ev))\n```\n\n\nTracking hourly is disabled (to save memory!) You can enable it with a\nconstructor argument.\n\n```python\nb = bitmapist4.Bitmapist(track_hourly=True)\n```\n\nAdditionally you can supply an extra argument to `mark_event` to bypass the default value::\n\n```python\nb.mark_event('active', 123, track_hourly=False)\n```\n\n\n## Unique events\n\nSometimes data of the event makes little or no sense and you are more interested\nif that specific event happened at least once in a lifetime for a user. \n\nThere is a `UniqueEvents` model for this purpose. The model creates only one\nRedis key and doesn't depend on the date.\n\nYou can combine unique events with other types of events.\n\nA/B testing example:\n\n```python\n\nactive = b.DailyEvents('active')\na = b.UniqueEvents('signup_form:classic')\nb = b.UniqueEvents('signup_form:new')\n\nprint(\"Active users, signed up with classic form\", len(active & a))\nprint(\"Active users, signed up with new form\", len(active & b))\n```\n\nYou can mark these users with `b.mark_unique` or you can automatically\npopulate the extra unique cohort for all marked keys\n\n```python\nb = bitmapist4.Bitmapist(track_unique=True)\nb.mark_event('premium', 1)\nassert 1 in b.UniqueEvents('premium')\n``` \n\n## Perform bit operations\n\nHow many users that have been active last month are still active this month?\n\n```python\nev = b.MonthEvents('active')\nactive_2months = ev & ev.prev() \nprint(len(active_2months))\n\n# Is 123 active for 2 months?\nassert 123 in active_2months\n```\n\nOperators `&`, `|`, `^` and `~` supported.\n\nThis works with nested bit operations (imagine what you can do with this ;-))!\n\n\n## Delete events\n\nIf you want to permanently remove marked events for any time period you can use the `delete()` method:\n\n```python\nev = b.MonthEvents.from_date('active', last_month)\nev.delete()\n```\n\nIf you want to remove all bitmapist events use:\n```python\nb.delete_all_events()\n```\n\nResults of bit operations are cached by default. They're cached for 60 seconds\nfor operations, contained non-finished periods, and for 24 hours otherwise.\n\nYou may want to reset the cache explicitly:\n\n```python\nev = b.MonthEvents('active')\nactive_2months = ev & ev.prev() \n# Delete the temporary AND operation\nactive_2months.delete()\n\n# delete all bit operations (slow if you have many millions of keys in Redis)\nb.delete_temporary_bitop_keys()\n```\n\n## Bulk updates with transactions\n\nIf you often performs multiple updates at once, you can benefit from Redis\npipelines, wrapped as transactions inside bitmapist.\n\n```python\nwith b.transaction():\n b.mark_event('active')\n b.mark_event('song:played')\n```\n\n\n# Migration from previous version\n\nThe API of the \"bitmapist4.Bitmapist\" instance is mostly compatible with the\nAPI of previous version of bitmapist (module-level). Notable changes outlined\nbelow.\n\n- Removed the \"system\" attribute for choosing the server. You are supposed to\n use different Bitmapist class instances instead. If you used \"system\" to\n work with pipelines, you should switch to transactions instead.\n- bitmapist.TRACK_HOURLY and bitmapist.TRACK_UNIQUE module-level constants\n moved to bitmapist4.Bitmapist attributes and can be set up with a class\n constructor.\n- On a database level, new bitmapist4 uses \"bitmapist_\" prefix for Redis keys,\n while old bitmapist uses \"trackist_\" for historical reasons. If you want\n to keep using the old database, or want to use bitmapist and bitmapist4\n against the same database, you need to explicitly set the key prefix\n to \"trackist_\".\n- If you use bitmapist-server, make sure that you use the version 1.2 or newer.\n This version adds the support for EXPIRE command which is used to expire\n temporary bitop keys.\n\n\nReplace old code which could look like this:\n\n```python\nimport bitmapist\nbitmapist.setup_redis('default', 'localhost', 6380)\n...\nbitmapist.mark_event('acive', user_id)\n```\n\nWith something looking like this:\n\n```python\nfrom bitmapist4 import Bitmapist\nbitmapist = Bitmapist('redis://localhost:6380', key_prefix='trackist_')\n...\nbitmapist.mark_event('acive', user_id)\n```\n\n\n\n# Bitmapist cohort\n\nCohort is a group of subjects who share a defining characteristic (typically\nsubjects who experienced a common event in a selected time period, such as\nbirth or graduation).\n\nYou can get the cohort table using `bitmapist4.cohort.get_cohort_table()` \nfunction. \n\nEach row of this table answers the question \"what part of the `cohort`\nperformed `activity` over time\", and Nth cell of that row represents the\nnumber of users (absolute or in percent) which still perform the activity\nN days (or weeks, or months) after.\n\nEach new column of the cohort unfolds the behavior of different similar\ncohorts over time. The latest row displays the behavior of the cohort,\nprovided as an argument, the one above displays the behavior of the similar\ncohort, but shifted 1 day (or week, or month) ago, etc.\n\nFor example, consider following cohort statistics\n\n```\ntable = get_cohort_table(b.WeekEvents('registered'), b.WeekEvents('active'))\n```\n\nThis table shows what's the rate of registered users is still active\nthe same week after registration, then one week after, then two weeks\nafter the registration, etc.\n\nBy default the table displays 20 rows.\n\nThe first row represents the statistics from cohort of users, registered\n20 weeks ago. The second row represents the same statistics for users,\nregistered 19 week ago, and so on until finally the latest row shows users\nregistered this week. Naturally, the last row will contain only one cell,\nthe number of users that were registered this week AND were active this\nweek as well.\n\n\nThen you may render it yourself to HTML, or export to Pandas dataframe\nwith df() method.\n\nSample from user activity on http://www.gharchive.org/\n\n```python\nIn [1]: from bitmapist4 import Bitmapist, cohort\n\nIn [2]: b = Bitmapist()\n\nIn [3]: cohort.get_cohort_table(b.WeekEvents('active'), b.WeekEvents('active'), rows=5, use_percent=False).df()\nOut[3]:\n cohort 0 1 2 3 4\n05 Nov 2018 137420 137420 25480.0 18358.0 21575.0 18430.0\n12 Nov 2018 150975 150975 22195.0 25833.0 21165.0 NaN\n19 Nov 2018 121417 121417 22477.0 15796.0 NaN NaN\n26 Nov 2018 152027 152027 25606.0 NaN NaN NaN\n03 Dec 2018 130470 130470 NaN NaN NaN NaN\n```\n\nThe dataframe can be further colorized (to be displayed in Jupyter notebooks)\nwith stylize().\n\n\n---\n\nCopyright: 2012-2018 by Doist Ltd.\n\nLicense: BSD\n\n\n", "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/Doist/bitmapist4", "keywords": "redis bitmap analytics bitmaps realtime cohort", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "bitmapist4", "package_url": "https://pypi.org/project/bitmapist4/", "platform": "Any", "project_url": "https://pypi.org/project/bitmapist4/", "project_urls": { "Homepage": "https://github.com/Doist/bitmapist4" }, "release_url": "https://pypi.org/project/bitmapist4/4.0/", "requires_dist": [ "redis (>=2.10)", "future (>=0.14)" ], "requires_python": "", "summary": "Powerful analytics library using Redis bitmaps", "version": "4.0" }, "last_serial": 4835374, "releases": { "4.0": [ { "comment_text": "", "digests": { "md5": "acb0e255c3bc2c2276bd93406dfcb76f", "sha256": "1f1a17cec134387d74506721bf70108bb671750c9d3bbfdc9aca950b28ebb6c8" }, "downloads": -1, "filename": "bitmapist4-4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "acb0e255c3bc2c2276bd93406dfcb76f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13744, "upload_time": "2018-12-11T10:58:30", "url": "https://files.pythonhosted.org/packages/2d/b1/b264ba7e84eac1f75d569a31b1938d04c491706f96f69e8e7d54fcc3442b/bitmapist4-4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1ea4bc68bbf62bba655cbadab3767179", "sha256": "09037d838ae7c5e90b12713d67869e040cc3e8892493fd186f233cdb3806e2f1" }, "downloads": -1, "filename": "bitmapist4-4.0.tar.gz", "has_sig": false, "md5_digest": "1ea4bc68bbf62bba655cbadab3767179", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18657, "upload_time": "2018-12-11T10:58:32", "url": "https://files.pythonhosted.org/packages/25/3f/9c49604844ed61e8c69671b580a701dd2d778d77cad6958a0a82c8b32290/bitmapist4-4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "acb0e255c3bc2c2276bd93406dfcb76f", "sha256": "1f1a17cec134387d74506721bf70108bb671750c9d3bbfdc9aca950b28ebb6c8" }, "downloads": -1, "filename": "bitmapist4-4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "acb0e255c3bc2c2276bd93406dfcb76f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13744, "upload_time": "2018-12-11T10:58:30", "url": "https://files.pythonhosted.org/packages/2d/b1/b264ba7e84eac1f75d569a31b1938d04c491706f96f69e8e7d54fcc3442b/bitmapist4-4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1ea4bc68bbf62bba655cbadab3767179", "sha256": "09037d838ae7c5e90b12713d67869e040cc3e8892493fd186f233cdb3806e2f1" }, "downloads": -1, "filename": "bitmapist4-4.0.tar.gz", "has_sig": false, "md5_digest": "1ea4bc68bbf62bba655cbadab3767179", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18657, "upload_time": "2018-12-11T10:58:32", "url": "https://files.pythonhosted.org/packages/25/3f/9c49604844ed61e8c69671b580a701dd2d778d77cad6958a0a82c8b32290/bitmapist4-4.0.tar.gz" } ] }