
Andrew Burns and Ib HansenAndrew Burns and Ib Hansen © 2025 International Bank for Reconstruction and Development / The World Bank1818 H Street NWWashington DC 20433Telephone: 202-473-1000Internet: www.worldbank.org This work is a product of the staff of The World Bank with external contributions. The findings,interpretations, and conclusions expressed in this work do not necessarily reflect the views of The WorldBank, its Board of Executive Directors, or the governments they represent.The World Bank does not guarantee the accuracy, completeness, or currency of the data included in this work and does not assume responsibility for any errors, omissions, or discrepancies in theinformation, or liability with respect to the use of or failure to use the information, methods, processes, orconclusions set forth. The boundaries, colors, denominations, links/footnotes and other informationshown in this work do not imply any judgment on the part of The World Bank concerning the legal statusof any territory or the endorsement or acceptance of such boundaries. The citation of works authored byothers does not mean the World Bank endorses the views expressed by those authors or the content oftheir works.Nothing herein shall constitute or be construed or considered to be a limitation upon or waiver of the privileges and immunities of The World Bank, all of which are specifically reserved. Rights and Permissions The material in this work is subject to copyright. Because The World Bank encourages dissemination ofits knowledge, this work may be reproduced, in whole or in part, for noncommercial purposes as long asfull attribution to this work is given.Any queries on rights and licenses, including subsidiary rights, should be addressed to World Bank Publications, The World Bank Group, 1818 H Street NW, Washington, DC 20433, USA; fax: 202-522-2625; e-mail: pubrights@worldbank.org. Cover design: Marie-Anne Chambonnier The World Bank's MFModFramework in Pythonwith Modelflow Andrew Burns and Ib HansenAndrew Burns and Ib Hansen https://reproducibility.worldbank.org A reproducibility package is available for this bookin the Reproducible Research Repository at: https://reproducibility.worldbank.org/index.php/catalog/324. The World Bank's MFMod Frameworkin Python with Modelflow Andrew Burns and Ib Hansen Nov 15, 2025 IThe World Bank's MFMod Framework and Modelflow3 1Introduction5 1.1The MFMod Framework at the World Bank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.2Early steps to bring the MFMod system to the broader economics community. . . . . . . . . . . . .61.3Moving the framework to an open-source footing. . . . . . . . . . . . . . . . . . . . . . . . . . . .7 2Macrostructural models2.1A system of equations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2The MFMod Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 3Installation13 3.1Installation of Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2Installation ofModelFlow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153.3Updating ModelFlow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 IISome python essentials for using World Bank models with modelflow19 4Introduction to Jupyter Notebook21 4.1Starting Jupyter Notebook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.2Creating a notebook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234.3Jupyter Notebook cells. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 5Some Python basics30 5.1Starting python in windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315.2Python packages, libraries and classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .325.3Importing packages, libraries, modules and classes . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 6.1Import the pandas library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .366.2TheSeriesclass inPandas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .366.3TheDataFrameclass inPandas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .396.4Selected pandas methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426.5The .loc[] method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 7ModelFlow and Pandas DataFrames7.1Column names in ModelFlow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507.2.index and time dimensions in ModelFlow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50 7.3Leads and lags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .