{ "info": { "author": "Elaine T. Hale", "author_email": "elaine.hale@nrel.gov", "bugtrack_url": null, "classifiers": [], "description": "gdx-pandas: Python package to translate between gdx (GAMS data) and pandas. \n\nUSE\n\nThere are two main ways to use gdxpds. The first use case is the one that was \ninitially supported: direct conversion between GDX files on disk and pandas \nDataFrames or a csv version thereof. The Version 1.0.0 rewrite intoduces a \nsecond style of use, that is, interfacing with GDX files and symbols via the \n`gdxpds.gdx.GdxFile` and `gdxpds.gdx.GdxSymbol` classes.\n\nUSE -- Direct Conversion\n\nThe two primary points of reference for the direct conversion utilities are GDX \nfiles on disk and python dicts of {symbol_name: pandas.DataFrame}, where \neach pandas.DataFrame contains data for a single set, parameter, equation, or \nvariable. For sets and parameters, the last column of the DataFrame is assumed to\ncontain the value of the element, which for sets should be `True`, and for \nparameters should be a `float` (or one of the `gdxpds.gdx.NUMPY_SPECIAL_VALUES`). \nEquations and variables have additional 'value' columns, in particular a level, \na marginal value, a lower bound, an upper bound, and a scale, as enumerated in \n`gdxpds.gdx.GamsValueType`. These values are all assumed to be found in the last \nfive columns of the DataFrame, also see `gdxpds.gdx.GAMS_VALUE_COLS_MAP`.\n\nThe basic interface to convert from GDX to DataFrames is:\n\nimport gdxpds\n\ngdx_file = 'C:\\path_to_my_gdx\\data.gdx'\ndataframes = gdxpds.to_dataframes(gdx_file)\nfor symbol_name, df in dataframes.items():\n print(\"Doing work with {}.\".format(symbol_name))\n\nAnd vice-versa:\n\nimport gdxpds\n\n# assume we have a DataFrame df with last column 'value'\ndata_ready_for_GAMS = { 'symbol_name': df }\n\ngdx_file = 'C:\\path_to_my_output_gdx\\data_to_send_to_gams.gdx'\ngdx = gdxpds.to_gdx(data_ready_for_GAMS, gdx_file)\n\nNote that providing a gdx_file is optional, and the returned gdx is an object of \ntype `gdxpds.gdx.GdxFile`.\n\nThe package also includes command line utilities for converting between GDX and \nCSV: gdx_to_csv.py and csv_to_gdx.py.\n\nUSE -- Backend Classes\n\nThe basic functionalities described above can also be achieved with direct use\nof the backend classes now available in `gdxpds.gdx`. To duplicate the GDX read \nfunctionality shown above one would write:\n\nimport gdxpds\n\ngdx_file = 'C:\\path_to_my_gdx\\data.gdx'\nwith gdxpds.gdx.GdxFile(lazy_load=False) as f:\n f.read(gdx_file)\n for symbol in f:\n symbol_name = symbol.name\n df = symbol.dataframe\n print(\"Doing work with {}:\\n{}\".format(symbol_name,df.head()))\n\nThe backend especially gives more control over creating new data in GDX format. \nFor example:\n\nimport gdxpds\n\nout_file = 'my_new_gdx_data.gdx'\nwith gdxpds.gdx.GdxFile() as gdx:\n # Create a new set with one dimension\n gdx.append(gdxpds.gdx.GdxSymbol('my_set',gdxpds.gdx.GamsDataType.Set,dims=['u']))\n data = pds.DataFrame([['u' + str(i)] for i in range(1,11)])\n data['Value'] = True\n gdx[-1].dataframe = data\n # Create a new parameter with one dimension\n gdx.append(gdxpds.gdx.GdxSymbol('my_parameter',gdxpds.gdx.GamsDataType.Parameter,dims=['u']))\n data = pds.DataFrame([['u' + str(i), i*100] for i in range(1,11)],\n columns=(gdx[-1].dims + gdx[-1].value_col_names))\n gdx[-1].dataframe = data\n gdx.write(out_file)\n\n\nDEPENDENCIES\n\n- Python 2.6 or higher 2.X; Python 3.4 or higher 3.X\n- pandas (In general you will want the SciPy stack. Anaconda comes with it, or see [my notes for Windows](http://elainethale.wordpress.com/programming-notes/python-environment-set-up/).)\n- For Python versions < 3.4, enum34. Also **uninstall the enum package** if it is installed.\n- psutil (optional--for monitoring memory use)\n- pytest (optional--for running tests)\n- GAMS Python bindings\n - See GAMS/win64/XX.X/apifiles/readme.txt on Windows, \n GAMS/gamsXX.X_osx_x64_64_sfx/apifiles/readme.txt on Mac, or \n /opt/gams/gamsXX.X_linux_x64_64_sfx/apifiles/readme.txt on Linux\n - Run the following for the correct version of the Python bindings\n \n python setup.py install\n \n or \n\n python setup.py build --build-base=/path/to/somwhere/you/have/write/access install\n \n with the latter being for the case when you can install packages into \n Python but don't have GAMS directory write access.\n\n - .../apifiles/Python/api/setup.py works for Python 2.7\n - For other versions of Python, especially 3.X, use \n .../apifiles/Python/api_XX/setup.py. For Python 3.X in particular you will \n need GAMS version >= 24.5.1 (Python 3.4, Windows and Linux), \n 24.7.4 (Python 3.4, Mac OS X), or >= 24.8.4 (Python 3.6)\n\n\nTESTING\n\nAfter installation, you can test the package using pytest:\n\npytest --pyargs gdxpds\n\nIf the tests fail due to permission IOErrors, apply `chmod g+x` and `chmod a+x` \nto the `gdx-pandas/gdxpds/test` folder.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/NREL/gdx-pandas", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "gdxpds", "package_url": "https://pypi.org/project/gdxpds/", "platform": "", "project_url": "https://pypi.org/project/gdxpds/", "project_urls": { "Homepage": "https://github.com/NREL/gdx-pandas" }, "release_url": "https://pypi.org/project/gdxpds/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "Python package to translate between gdx (GAMS data) and pandas.", "version": "1.1.0" }, "last_serial": 4357368, "releases": { "1.0.3": [ { "comment_text": "", "digests": { "md5": "057b672a8163df0d0814a96ed09a14a2", "sha256": "7c33a7017c3de53337f40cbfada4442585a9e3de51458799ba0976a6a70e3037" }, "downloads": -1, "filename": "gdxpds-1.0.3.tar.gz", "has_sig": false, "md5_digest": "057b672a8163df0d0814a96ed09a14a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 635660, "upload_time": "2018-02-21T23:44:20", "url": "https://files.pythonhosted.org/packages/03/22/28f6260496bcdd56841d768e0b6bdb8b4c799bcd30f0354ac1d6c45a9550/gdxpds-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "13ed6cb1259d253776e483b9196f2519", "sha256": "8caac805b12c238113dbe0e897579c45ab9950d50bb3f77c884663423a0eeee5" }, "downloads": -1, "filename": "gdxpds-1.0.4.tar.gz", "has_sig": false, "md5_digest": "13ed6cb1259d253776e483b9196f2519", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 635916, "upload_time": "2018-03-02T17:56:17", "url": "https://files.pythonhosted.org/packages/21/2d/c8de08f5522ca66980b0c23f7036b25d5a48a068ceab9cd5ef560133c44c/gdxpds-1.0.4.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "61d6c54a06643636b01a951df89ecde0", "sha256": "a410718b5a9b122019273d5cbf7182c792bcd8d00896d463f49cbabda494e87d" }, "downloads": -1, "filename": "gdxpds-1.1.0.tar.gz", "has_sig": false, "md5_digest": "61d6c54a06643636b01a951df89ecde0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 641629, "upload_time": "2018-10-09T19:56:51", "url": "https://files.pythonhosted.org/packages/d3/08/a5e5df9a8844d0a63759f78deff93279e59a720b5762fab60bf25fa93637/gdxpds-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "61d6c54a06643636b01a951df89ecde0", "sha256": "a410718b5a9b122019273d5cbf7182c792bcd8d00896d463f49cbabda494e87d" }, "downloads": -1, "filename": "gdxpds-1.1.0.tar.gz", "has_sig": false, "md5_digest": "61d6c54a06643636b01a951df89ecde0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 641629, "upload_time": "2018-10-09T19:56:51", "url": "https://files.pythonhosted.org/packages/d3/08/a5e5df9a8844d0a63759f78deff93279e59a720b5762fab60bf25fa93637/gdxpds-1.1.0.tar.gz" } ] }