{ "info": { "author": "Amine TEFFAL", "author_email": "a.teffal@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# pop_projection\n\nProjection of a population of a retirement plan consisting of :\n- employees (actives and retirees)\n- their spouses\n- thier childrens\n\n\nGiven such population at the end of year 0, we compute, for each following year (year 1, year 2, ..., year 100, and at the end of that year), the number of individuals, that survived, died and quit the company (actives only) and those that retired (actives only). In addition to that, new spouses, new children, and new actives are also generated using given laws.\n\nThe laws governing suchs movements are :\n\n- law of mortality (mortality tables)\n- law of quitting\n- law of retirement (this one is in fact deterministic : retirement at some age , 60 for example)\n- law of marriage\n- law of birth\n- law of replacement\n\nThis laws (except law of replacement) are passed as functions or as a tuple of two elements, the fist one is a function, and the second one is a list of its parameters. The names of this parameters must exist in the list of columns of the dataframes employees, spouses or children (depending on the law. See below).\nif the law is passed as function only, the names of the parameters used in the signature of the function must exist in the list of columns of the dataframes employees, spouses or children (depending on the law. See below).\n\nLaw of replacement is passed as function.\n\n**Parameters of laws**\n- law of quitting --> parameters names are in the list of columns of employees.\n- law of retirement --> parameters names are in the list of columns of employees.\n- law of marriage --> parameters names are in the list of columns of employees.\n- law of birth --> parameters names are in the list of columns of spouses.\n- law of replacement has two parameters : \n - a dic storing number of departures of year year_ by group (employees who retired, resigned or died in year year_)\n - year of departure\n\n**Return values of laws**\n\n- law of quitting --> probablity that the employee will quit before the end of the next year.\n- law of retirement --> 1 if the employee will retire before the end of the next year, 0 otherwise.\n- law of marriage --> probablity that the employee will marry before the end of the next year.\n- law of birth --> probablity that the spouse (if female) or his wife will give birth before the end of the next year.\n- law of replacement --> a list of employees to add to population. Each employee in this list is a dic with keys : 'key' (to uniquely define the employee), 'number' and 'data' (list of values that corresponds to columns in employee except id).\n\n# Installation\n```\npip install pop-projection\n```\n# Usage example\n\n```\nimport pop_projection.Effectifs as eff\nimport pop_projection.Actuariat as act\nimport pandas as pd\n\n# Define law of retirement\ndef law_ret1(age, Year_employment):\n if Year_employment < 2002:\n if age+1 >= 55:\n return True\n else:\n return False\n if Year_employment >= 2002:\n if age+1 >= 60:\n return True\n else:\n return False\n\n# Define law of reignation\ndef law_resignation_1(age, sex):\n if age+1 >= 50 :\n return 0\n if sex == 'female':\n if age+1 <= 30:\n return 0.02\n else:\n return 0.01\n if sex == 'male':\n if age+1 <= 30:\n return 0.02\n else:\n return 0.01\n\n\n\n# Define law of marriage\ndef law_mar1(age, sexe, typeAgent):\n \"\"\"\n Return the probability of getting maried during the following year at a given age for a given sex\n\n \"\"\"\n if sexe == 'male':\n if typeAgent=='active':\n if age >= 25 and age <= 54:\n return 0.095\n else :\n return 0\n else:\n return 0\n\n if sexe == 'female':\n if typeAgent=='active':\n if age >= 25 and age <= 54:\n return 0.15\n else :\n return 0\n else:\n return 0\n\n\n# Define law of replacement \ndef law_replacement1(departures_, year_):\n\n '''\n assumes departures_ is a dic storing number of departures by group of the year year_\n returns a list of dics having keys : key, number and data\n\n '''\n def nouveaux(g_):\n structure_nouveaux = {'1':[25,25,0.8],'2':[25,25,0.8],'3':[25,25,0.6],'4':[29,29,0.6],'5':[28,28,0.5,],\n '6':[28,28,0.5],'7':[33,33,0.5],'8':[38,38,0.5],'9':[38,38,0.5],'10':[47,47,0.5],'11':[49,49,0.5]}\n\n if str(g_) in structure_nouveaux:\n return structure_nouveaux[str(g_)]\n else:\n return [30, 30, 1.0]\n\n def taux_rempl(y, g_ = '0'):\n if y <= 3 :\n if str(g_) in ['1','2','3','5','6','7']:\n return 0.64\n else:\n return 1\n else:\n return 1\n\n new_employees = []\n\n for g in departures_:\n # add a male\n if nouveaux(g)[2] > 0:\n temp = {'key':'male_groupe_' + str(g) + 'year_' + str(year_), \n 'number':nouveaux(g)[2]*departures_[g]*taux_rempl(year_, g),'data':['active', 'male', 'not married', nouveaux(g)[0], year_,g,'01/01/'+str((2018+year_+1)),'31/12/'+str((2018+year_-nouveaux(g)[0]))]}\n new_employees.append(temp)\n\n # add a female\n if nouveaux(g)[2] < 1:\n temp = {'key':'female_groupe_' + str(g) + 'year_' + str(year_), \n 'number':(1-nouveaux(g)[2])*departures_[g]*taux_rempl(year_, g),'data':['active', 'female', 'not married', nouveaux(g)[1], year_,g,'01/01/'+str((2018+year_+1)),'31/12/'+str((2018+year_-nouveaux(g)[1]))]}\n new_employees.append(temp)\n\n return new_employees\n\n# Path for input data\npath =\"./pop_projection/data/\"\n\n# Number of years to project\nMAX_YEARS = 50\n\n# Loading data\nemployees = pd.read_csv(path + \"employees.csv\",sep=\";\", decimal = \",\")\nspouses = pd.read_csv(path + \"spouses.csv\",sep=\";\", decimal = \",\")\nchildren = pd.read_csv(path + \"children.csv\",sep=\";\", decimal = \",\")\n\n# View existing mortality tables\nprint('Mortality tables : \\n',list(act.mortality_tables.keys()))\n\n# Add the 2009 usa table\ntable_usa_2009 = pd.read_csv(\"table_usa_2009.csv\",sep=\";\", decimal = \",\")\nact.add_mortality_table('table_usa_2009', list(table_usa_2009['Lx']))\n\n# Projection of population\nnumbers_ = eff.simulerEffectif(employees, spouses, children, 'table_usa_2009', MAX_YEARS, \n law_retirement_= law_ret1, law_resignation_= law_resignation_1, \n law_marriage_= (law_mar1, ['age', 'sex', 'type']), law_replacement_= law_replacement1)\n\n# Global numbers\nEffectifs = eff.globalNumbers(numbers_[0], numbers_[1], numbers_[2], MAX_YEARS)\n\n# Print some lines\nprint(Effectifs.head(10))\n\n# Export Effectifs\nEffectifs.to_csv('Effectifs_python.csv', sep = ';', index=False, decimal=',')\n\n#Number of actives leaving population : deaths, resignations, and new retired\nLeaving = eff.leavingNumbers(numbers_[0], numbers_[4], MAX_YEARS)\n\n#Print some lines\nprint(Leaving.head(10))\n\n#Export Leaving\nLeaving.to_csv('Sortants_python.csv', sep = ';', index=False, decimal=',')\n\n#export projected employees\npd.DataFrame.from_dict(numbers_[0]).to_csv('employees_proj.csv', sep = ';', index=False, decimal=',')\n\n#export projected spouses\npd.DataFrame.from_dict(numbers_[1]).to_csv('spouses_proj.csv', sep = ';', index=False, decimal=',')\n\n#export projected children\npd.DataFrame.from_dict(numbers_[2]).to_csv('children_proj.csv', sep = ';', index=False, decimal=',')\n```\n# Other examples : \n\n[Plotting Evolution of Ages pyramid over years]( https://github.com/ateffal/pop_projection/blob/master/usage_examples/usage_example_1.md)\n\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/ateffal/pop_projection", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pop-projection", "package_url": "https://pypi.org/project/pop-projection/", "platform": "", "project_url": "https://pypi.org/project/pop-projection/", "project_urls": { "Homepage": "https://github.com/ateffal/pop_projection" }, "release_url": "https://pypi.org/project/pop-projection/2.1.0/", "requires_dist": null, "requires_python": "", "summary": "Projection of population of a retirement plan.", "version": "2.1.0" }, "last_serial": 5437031, "releases": { "0.1.4": [ { "comment_text": "", "digests": { "md5": "77c1ab7ede216510336da8fb441622be", "sha256": "bfe5f11361ed2565a8f5fbceaa9d9fbd7af1726a8dde0805ab5cb6de7aa14383" }, "downloads": -1, "filename": "pop_projection-0.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "77c1ab7ede216510336da8fb441622be", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12967, "upload_time": "2018-12-14T15:24:33", "url": "https://files.pythonhosted.org/packages/3d/86/1e8fcfa4a6d2322e0bf764036a4a97ceb3fb2994badb9ea59da2318035e3/pop_projection-0.1.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7a74881a27cf0ccf4e1a7a017b222728", "sha256": "734d7f0631ed4281609a84c2917e236d1377693431f5ac83277fda54c050f328" }, "downloads": -1, "filename": "pop_projection-0.1.4.tar.gz", "has_sig": false, "md5_digest": "7a74881a27cf0ccf4e1a7a017b222728", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12626, "upload_time": "2018-12-14T15:24:40", "url": "https://files.pythonhosted.org/packages/5e/82/b00a4dcfc92fbef37b7975c28e11225154146814b348ad530f71e2c4f319/pop_projection-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "dcb94613d76b9c6ae81538c246d047f6", "sha256": "36bf6af2084c99fb9012c265a4bf12f853e0dcdc7f6d93e7498c750764bcc2b7" }, "downloads": -1, "filename": "pop_projection-0.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dcb94613d76b9c6ae81538c246d047f6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16672, "upload_time": "2018-12-18T08:11:41", "url": "https://files.pythonhosted.org/packages/84/c4/f4940049ca2ac63ed6e1b2affdfba28d097532adb884bdaf1e214b50c6ef/pop_projection-0.1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4ec7aa936573be9e5b2e75f274f8ee31", "sha256": "dc485b6958022a2d5cbe65251658b231906f21e50048492e2c7bd9a2402b4881" }, "downloads": -1, "filename": "pop_projection-0.1.5.tar.gz", "has_sig": false, "md5_digest": "4ec7aa936573be9e5b2e75f274f8ee31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16375, "upload_time": "2018-12-18T08:11:48", "url": "https://files.pythonhosted.org/packages/cf/0c/4d098052f3c5f27a354c30606211f37b7682247044556df5ac3cf2e3603f/pop_projection-0.1.5.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "8eb7bc3c322cd80198a0a56a5815eafc", "sha256": "50bf4bf2b1713f0843afd79d7733c59d8b160338b0922214356fc6e211dfbf92" }, "downloads": -1, "filename": "pop_projection-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8eb7bc3c322cd80198a0a56a5815eafc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17147, "upload_time": "2019-03-28T14:25:40", "url": "https://files.pythonhosted.org/packages/49/40/11ca0fed8760f96d46549c2dbd4f6daa4790669de1ff6600aa34fbdf0fe9/pop_projection-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d33b8918b68ab9b94d5d80401a401972", "sha256": "05e9b64c97f82f33a1373a14927e7cb6305f164dd5b1e516958d1828d720e39f" }, "downloads": -1, "filename": "pop_projection-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d33b8918b68ab9b94d5d80401a401972", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17289, "upload_time": "2019-03-28T14:25:47", "url": "https://files.pythonhosted.org/packages/c2/52/1073d9588ea69ad81e5b9ddf2da7b8516e71bae94880ba19a9aad3b64d7d/pop_projection-1.0.0.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "7e8c6e9f8f47114984027695c71d96ed", "sha256": "e374c1d62d051d21badcd9e024e7e6618ee221ac6e0319f7e75d40ad13e36ecd" }, "downloads": -1, "filename": "pop_projection-2.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7e8c6e9f8f47114984027695c71d96ed", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 19125, "upload_time": "2019-04-29T14:53:51", "url": "https://files.pythonhosted.org/packages/66/a1/ebb594ba003d937f052784b93db607483374c441a7169bc7f6f5f12aa104/pop_projection-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "42e42b3adb120cc14797e304c097a94e", "sha256": "c8c42caec3acd29bb7e49497e369139bea2da074d392d6e6bca90a523b07a7aa" }, "downloads": -1, "filename": "pop_projection-2.0.0.tar.gz", "has_sig": false, "md5_digest": "42e42b3adb120cc14797e304c097a94e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18524, "upload_time": "2019-04-29T14:53:57", "url": "https://files.pythonhosted.org/packages/4f/ad/51fa17a6fbef94ba0c2d0a6ed500dd3dc47958b8c9d9367238251c310c46/pop_projection-2.0.0.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "c39b62899e627cbe75847f75762c8639", "sha256": "ac5aee601a3b4917d002b9fa67ed49e5a90f1e244ee99771f84344bebd1cd6bd" }, "downloads": -1, "filename": "pop_projection-2.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c39b62899e627cbe75847f75762c8639", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 21788, "upload_time": "2019-06-23T10:58:50", "url": "https://files.pythonhosted.org/packages/6f/10/e146bd5efba19fee9a14c8f1f719311daeafaaffa10a83452c7103673092/pop_projection-2.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3a290e72ad4d741cdbe12cb86a891fad", "sha256": "6464313583b74911f855f7977c740cefff98fdf6e67035dc588f4104e34f45c5" }, "downloads": -1, "filename": "pop_projection-2.1.0.tar.gz", "has_sig": false, "md5_digest": "3a290e72ad4d741cdbe12cb86a891fad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21062, "upload_time": "2019-06-23T10:58:54", "url": "https://files.pythonhosted.org/packages/5e/f5/741fba933786541ea59a953d671ec029b7684e78a132a7775fca11e35b50/pop_projection-2.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c39b62899e627cbe75847f75762c8639", "sha256": "ac5aee601a3b4917d002b9fa67ed49e5a90f1e244ee99771f84344bebd1cd6bd" }, "downloads": -1, "filename": "pop_projection-2.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c39b62899e627cbe75847f75762c8639", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 21788, "upload_time": "2019-06-23T10:58:50", "url": "https://files.pythonhosted.org/packages/6f/10/e146bd5efba19fee9a14c8f1f719311daeafaaffa10a83452c7103673092/pop_projection-2.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3a290e72ad4d741cdbe12cb86a891fad", "sha256": "6464313583b74911f855f7977c740cefff98fdf6e67035dc588f4104e34f45c5" }, "downloads": -1, "filename": "pop_projection-2.1.0.tar.gz", "has_sig": false, "md5_digest": "3a290e72ad4d741cdbe12cb86a891fad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21062, "upload_time": "2019-06-23T10:58:54", "url": "https://files.pythonhosted.org/packages/5e/f5/741fba933786541ea59a953d671ec029b7684e78a132a7775fca11e35b50/pop_projection-2.1.0.tar.gz" } ] }