{ "info": { "author": "Pietro Giuffrida", "author_email": "pietro.giuffri@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# carbonium\n\nEasily manage a list of names with several\nproperties and (overlapping) order criteria.\n\n## Installation\n\nInstall carbonium is as easy as run \n```pip install carbonium```.\n\n## Usage\n\nAs first step you should define a name list:\n\n```python\nname_list = [\n {\n \"domains\": [\"raw\", \"output\"],\n \"name\": \"var1\",\n \"alias\": \"column_1_name\",\n \"output_order\": 1,\n \"filling_value\": 10,\n },\n {\n \"domains\": [\"raw\"],\n \"name\": \"var2\",\n \"alias\": \"column_2_name\",\n \"output_order\": 2,\n },\n {\n \"domains\": [\"new\", \"output\"],\n \"name\": \"new_var\",\n \"alias\": \"new_column_name\",\n },\n]\n```\n\nEach *name definition* is a dictionary that\ncontains some common, mandatory key, and some\nother keys, domain-specific or name-specific.\n\nMandatory keys are only three:\n\n- domains, a list of string, each representing a *domain*\n- name, a string, uniquely identifiers of a *name*\n- alias, a string that can be used to refers to\n the name in context where it is named with\n this alternative string.\n \nThen, each name belongs to some domains. Domains\nare used to perfom names selection (give me all\nnames belonging to *domain*). Names that belongs\nto the same domain should have the same optional\nattributes.\n\nAfter *name list* definition, you can instantiate\nthe structure class:\n\n```python\nfrom carbonium import Structure\n\nstructure = Structure(name_list)\n```\n\nInternally, the Structure class iteratively instantiate a\nName class for each *name definition*. After this\nstep you can access to each Name and its properties\nthrough ```c``` object, but you can also use one of\nproperty or method of the class.\n\n```python\nprint(structure.names)\n# returns: ['var1', 'var2', 'new_var']\n\nprint(structure.domains)\n# returns: {'new', 'output', 'raw'}\n\nprint(\n structure.var1.name,\n structure.var1.domains,\n structure.var1.output_order\n)\n```\n\nCalling *structure.var1.name* you have access to the\nstring associated to var1... and so on.\n\n```python\nordered_raw_columns = [\n (\n i,\n structure.get(i).output_order,\n structure.get(i).get(\"filling_value\")\n )\n for i in structure.get_names('raw')\n]\n\nordered_raw_columns = sorted(\n ordered_raw_columns,\n key=lambda x: x[1]\n)\n```\n\nIn this example all the names belonging to *raw*\ndomain are extracted with some other properties.\nIn this way the same name can be used in different\ndomains or contexts by referring to contexctual\nrelevant properties.\n\n```python\nimport pandas as pd\ndf = pd.DataFrame([\n {\"var1\": 100, \"var2\": 200},\n {\"var2\": 220},\n])\n\nfor name in structure.get_names('raw'):\n alias = structure.get(name).alias\n filling = structure.get(name).get(\"filling_value\")\n if filling:\n df[alias].fillna(filling, inplace=True)\n\nfor name in structure.get_names('new'):\n alias = structure.get(name).alias\n df[alias] = \"arbitrary\" \n\noutput_columns = structure.get_names('new')\ndf[output_columns].to_parquet('output.parquet')\n```\n\nAs you can see, whithout modify the code but only the\ntaxonomy described in *name_list*, you can affect\ndifferent columns.", "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/pietrogiuffrida/carbonium/", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "carbonium", "package_url": "https://pypi.org/project/carbonium/", "platform": "", "project_url": "https://pypi.org/project/carbonium/", "project_urls": { "Homepage": "https://github.com/pietrogiuffrida/carbonium/" }, "release_url": "https://pypi.org/project/carbonium/0.10.4/", "requires_dist": null, "requires_python": "", "summary": "Manage a list of names with several properties and (overlapping) order criteria", "version": "0.10.4" }, "last_serial": 5619997, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "2ff9bf5b66b2172824606fb70e0c4ab5", "sha256": "6fa503f52f6624edafac43744296f36fee259a636ad72789fcd771d0472f0504" }, "downloads": -1, "filename": "carbonium-0.1.tar.gz", "has_sig": false, "md5_digest": "2ff9bf5b66b2172824606fb70e0c4ab5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5774, "upload_time": "2019-07-19T00:06:03", "url": "https://files.pythonhosted.org/packages/bc/e3/08e7a7a36012ce748bcaf512c1fbf6c20bab8f24fed03a47a74fa7a9310a/carbonium-0.1.tar.gz" } ], "0.10.1": [ { "comment_text": "", "digests": { "md5": "7f5a45f99980624876242525036c076e", "sha256": "832721d63a6c2ce793461dd77cf7a6ba1390488e20440441b179f1895e852173" }, "downloads": -1, "filename": "carbonium-0.10.1.tar.gz", "has_sig": false, "md5_digest": "7f5a45f99980624876242525036c076e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6083, "upload_time": "2019-07-19T00:24:36", "url": "https://files.pythonhosted.org/packages/b6/4e/fbb700b081aa7d5d4583b05b4e5ddeb7dfd5a7b6de07cdb87a5e86e2df20/carbonium-0.10.1.tar.gz" } ], "0.10.2": [ { "comment_text": "", "digests": { "md5": "821e3fb2430662248692e101ccdd3877", "sha256": "168c8310057a4ab24e3f4531f9773f7cfa114321ca06415a747f4fa797fd32ea" }, "downloads": -1, "filename": "carbonium-0.10.2.tar.gz", "has_sig": false, "md5_digest": "821e3fb2430662248692e101ccdd3877", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6102, "upload_time": "2019-07-23T08:03:01", "url": "https://files.pythonhosted.org/packages/70/89/fba01193def2ca659f564e7712adfab7e14f12e4676f08374ecb3abe9600/carbonium-0.10.2.tar.gz" } ], "0.10.3": [ { "comment_text": "", "digests": { "md5": "af3ddb00009d9cab2492ccc00e50ea93", "sha256": "baedbf1becad4549111b7e3341f98649e9ad52c6aa5631549900e411ef884893" }, "downloads": -1, "filename": "carbonium-0.10.3.tar.gz", "has_sig": false, "md5_digest": "af3ddb00009d9cab2492ccc00e50ea93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6110, "upload_time": "2019-07-23T17:39:33", "url": "https://files.pythonhosted.org/packages/1e/49/64456be9c23c22a8980b227e00834c002aacbc1f6b190a41a61002f06e7a/carbonium-0.10.3.tar.gz" } ], "0.10.4": [ { "comment_text": "", "digests": { "md5": "e8bcb5910029e465dd3e3a3baaee1af4", "sha256": "f5c2db0b5d118f024f5e72dc9186a2d7c2cf194a99ac0ddc9d69756322fa4d1c" }, "downloads": -1, "filename": "carbonium-0.10.4.tar.gz", "has_sig": false, "md5_digest": "e8bcb5910029e465dd3e3a3baaee1af4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6298, "upload_time": "2019-08-01T18:03:36", "url": "https://files.pythonhosted.org/packages/8e/4b/78250631f8a912fb76e98a2bdbb52265ce7765aebe01ff97080058eb1f80/carbonium-0.10.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e8bcb5910029e465dd3e3a3baaee1af4", "sha256": "f5c2db0b5d118f024f5e72dc9186a2d7c2cf194a99ac0ddc9d69756322fa4d1c" }, "downloads": -1, "filename": "carbonium-0.10.4.tar.gz", "has_sig": false, "md5_digest": "e8bcb5910029e465dd3e3a3baaee1af4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6298, "upload_time": "2019-08-01T18:03:36", "url": "https://files.pythonhosted.org/packages/8e/4b/78250631f8a912fb76e98a2bdbb52265ce7765aebe01ff97080058eb1f80/carbonium-0.10.4.tar.gz" } ] }