{ "info": { "author": "Arthur Street", "author_email": "arthur@artana.com.au", "bugtrack_url": null, "classifiers": [], "description": "# Monte Carlo Business Case Analysis using pandas\n\nThis package provides some tools and examples to analyse high-impact business decisions, and dodge many of the problems of using spreadsheets.\n\n## Background\n\nPandas is increasingly becoming a standard tool in scientific computing. Could it also have a role in the CFO's office? CFOs regularly need to analyse the impact of different projects or business cases, and they almost universally do this using spreadsheets. Spreadsheets have many advantages - they have a low barrier to entry and are easy for most people to understand. However as they get more complicated, disadvantages start to appear; in particular, they can be inflexible and highly error-prone. \n\nThe application here is made more interesting and useful by being 'Monte Carlo' analysis. Traditional business case analysis takes single point estimates of sales, costs and prices, and calculates a single profit forecast. Everybody knows the profit will not turn out to be exactly equal to the forecast. But it is not clear what the range of profits might be, or how likely a loss is. 'Monte Carlo' analysis solves this problem by allowing ranges or distributions on the assumptions; the forecast is then a range of outcomes. \n\nFor more background, see the [talk](http://racingtadpole.com/blog/business-case-python-pandas/).\n\n## Package structure\n\nSlides and an ipython notebook are included in the `talks` directory. The talk, titled \"Monte Carlo Business Case Analysis using pandas\", was presented at the Science and Data mini-conference for PyCon Australia (1 Aug 2014), as well as the Sydney Python group on 5 June 2014. It is an introduction to both Monte Carlo Business Case Analysis and pandas. You can find it online at [racingtadpole.com/blog/business-case-python-pandas](http://racingtadpole.com/blog/business-case-python-pandas/). The slides have been prepared using the html5 presentation engine [Shower](https://github.com/shower/shower).\n\nThe `montepylib` directory includes: \n\n- `io.py` - routines to simplify data input\n- `manip.py` - routines to manipulate DataFrames\n- `utils.py` - utility routines like `is_string_int`\n- `sim.py` - the core simulation routines\n- `extend.py` - adds some useful methods to `DataFrame`\n\nSee the `examples` directory for more, including testing your model.\n\n\n## Quick start\n\nFirst install the package:\n\n pip install montepylib\n\nThen, in python, try:\n\n from pandas import Series, DataFrame\n import pandas as pd\n from montepylib.sim import Simulator\n\n volume = DataFrame([['Factory A','Widget X',200,30.0],['Factory A','Widget Y',100,15.0],['Factory B','Widget X',300,50.0]], columns=['factory','widget','mean','sd'])\n costs = DataFrame([['Factory A','Widget X',1,.2],['Factory A','Widget Y',.6,.1],['Factory B','Widget X',1.2,.25],['Factory B','Widget Y',.7,.12]], columns=['factory','widget','mean','sd'])\n price = DataFrame([['Widget X',5,.5], ['Widget Y',3,.3]], columns=['widget','mean','sd'])\n\n mc = Simulator()\n N = 5000\n sim_vol = mc.sim_from_params(N, volume, 'volume')\n sim_costs = mc.sim_from_params(N, costs, 'cost')\n sim_price = mc.sim_from_params(N, price, 'price')\n\n sim = mc.merge(sim_vol, sim_costs, sim_price, how='left')\n sim['margin'] = sim['price'] - sim['cost']\n sim['profit'] = sim['volume'] * sim['margin']\n\n sim_factory = sim.groupby(['factory', 'iteration']).sum()[['profit','volume']]\n total_per_iteration = sim_factory.groupby(level='iteration').sum()\n total_per_iteration.hist(xrot=90);\n\n summary_per_factory = sim_factory.groupby(level='factory').describe().unstack(level=0)\n summary_per_factory\n # profit volume \n # factory Factory A Factory B Factory A Factory B\n # count 5000.000000 5000.000000 5000.000000 5000.000000\n # mean 1041.392873 1142.445923 299.692542 300.461622\n # std 167.320088 255.161823 33.146621 50.388224\n # min 411.263495 370.741291 150.234686 127.378759\n # 25% 929.578744 965.513249 277.282007 266.361845\n # 50% 1032.065933 1129.047618 299.882982 300.278990\n # 75% 1148.330681 1308.399140 321.756739 334.676815\n # max 1808.573213 2167.622599 420.227083 478.421165\n\nFor the base case, use `N = 0`:\n\n N = 0\n # include the same code as above to calculate sim_factory\n sim_factory\n # profit volume\n # factory iteration \n # Factory A base case 1040 300\n # Factory B base case 1140 300\n\nFor sensitivity analysis, use `N = -1`:\n\n N = -1\n # include the same code as above to calculate total_per_iteration\n total_per_iteration\n # profit volume\n # iteration \n # base case 2180 600\n # high cost 2055 600\n # high price 2460 600\n # high volume 2526 695\n # low cost 2305 600\n # low price 1900 600\n # low volume 1834 505\n\nSee the `examples` directory for a more detailed example, including testing your model.\n\n\n## Other implementations\n\nPandas is not the only way to do this. For another approach, I have also explored using R - see [this post](http://racingtadpole.com/blog/monte-carlo-cashflow-modelling-in-r/) for some examples, and see the book [\"Business Case Analysis with R\"](http://leanpub.com/bizanalysiswithr) by Robert D. Brown, 2013. Or if you want to free yourself from using simulations and deal directly with mathematical distributions, you could even use [Mathematica](http://www.wolfram.com/mathematica/)...", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/artstr/montepylib", "keywords": "business,cashflows,analysis,decision,spreadsheet,monte carlo,finance,corporate", "license": "BSD LICENSE", "maintainer": null, "maintainer_email": null, "name": "montepylib", "package_url": "https://pypi.org/project/montepylib/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/montepylib/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/artstr/montepylib" }, "release_url": "https://pypi.org/project/montepylib/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Tools and examples to analyse high-impact business decisions, and dodge many of the problems of using spreadsheets", "version": "0.1.0" }, "last_serial": 1181478, "releases": { "0.0.1": [], "0.0.2": [ { "comment_text": "", "digests": { "md5": "3562da75fba86e6bf5052b07505298de", "sha256": "045aa6b6804c1bf4d8a6a1e21a9bbe010de38bafd9c1f2e5314465f77f24c99f" }, "downloads": -1, "filename": "montepylib-0.0.2.tar.gz", "has_sig": false, "md5_digest": "3562da75fba86e6bf5052b07505298de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2002242, "upload_time": "2014-08-06T02:44:25", "url": "https://files.pythonhosted.org/packages/f2/e5/71bf900d9d72ce0ab09e80ed46ecbfeace45359aac13d28d3485bb0c8322/montepylib-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "6fb19a6da827be4642d90b91956dc0a8", "sha256": "74bcdd01e6007114d8dfe095983dd29caa440926a506548c57cb7eea533c4589" }, "downloads": -1, "filename": "montepylib-0.0.3.tar.gz", "has_sig": false, "md5_digest": "6fb19a6da827be4642d90b91956dc0a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2002179, "upload_time": "2014-08-06T03:27:55", "url": "https://files.pythonhosted.org/packages/56/55/7252dbeb81bdbed18c82c8e74fae1c7b9bc14219638a660e94e196fd0972/montepylib-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "2546c271a42c7e2ca18e5155ccf9011a", "sha256": "e25c2d43cfd7d9877c25f13b1471a8f82c1a2203d613587d9c37ea35e49ebd83" }, "downloads": -1, "filename": "montepylib-0.0.4.tar.gz", "has_sig": false, "md5_digest": "2546c271a42c7e2ca18e5155ccf9011a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2004682, "upload_time": "2014-08-06T03:49:05", "url": "https://files.pythonhosted.org/packages/7f/32/7a175b83743e53d0deaff41776b6dae8512f2df70789d12e82b856ab6f34/montepylib-0.0.4.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "2d976bd88fd110ab7666a0e267a53d7c", "sha256": "b499f251af9a2798b51d33e415e497e5f9a3b911a459909c4683eb738e221a11" }, "downloads": -1, "filename": "montepylib-0.1.0.tar.gz", "has_sig": false, "md5_digest": "2d976bd88fd110ab7666a0e267a53d7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2004725, "upload_time": "2014-08-06T08:05:10", "url": "https://files.pythonhosted.org/packages/e1/df/d35e8e32e2029f211dc89f9ab8ae318f4a0deaa2f64274c15b01a2de92f5/montepylib-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2d976bd88fd110ab7666a0e267a53d7c", "sha256": "b499f251af9a2798b51d33e415e497e5f9a3b911a459909c4683eb738e221a11" }, "downloads": -1, "filename": "montepylib-0.1.0.tar.gz", "has_sig": false, "md5_digest": "2d976bd88fd110ab7666a0e267a53d7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2004725, "upload_time": "2014-08-06T08:05:10", "url": "https://files.pythonhosted.org/packages/e1/df/d35e8e32e2029f211dc89f9ab8ae318f4a0deaa2f64274c15b01a2de92f5/montepylib-0.1.0.tar.gz" } ] }