edc-analytics


Nameedc-analytics JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/clinicedc/edc-analytics
SummaryBuild analytical tables for clinicedc/edc projects
upload_time2024-10-09 16:32:00
maintainerNone
docs_urlNone
authorErik van Widenfelt
requires_python>=3.12
licenseGPL license, see LICENSE
keywords django analytics pandas data collection clinicedc clinical trials
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |pypi| |downloads|


edc-analytics
-------------

Build analytic tables from EDC data


Read your data into a dataframe, for example an EDC screening table:

.. code-block:: python

    qs_screening = SubjectScreening.objects.all()
    df = read_frame(qs_screening)


Convert all numerics to ``pandas`` numerics:

.. code-block:: python

    cols = [
        "age_in_years",
        "dia_blood_pressure_avg",
        "fbg_value",
        "hba1c_value",
        "ogtt_value",
        "sys_blood_pressure_avg",
    ]
    df[cols] = df[cols].apply(pd.to_numeric)


Pass the dataframe to each ``Table`` class

.. code-block:: python

    gender_tbl = GenderTable(main_df=df)
    age_tbl = AgeTable(main_df=df)
    bp_table = BpTable(main_df=df)


In the ``Table`` instance,

* ``data_df`` is the supporting dataframe
* ``table_df`` is the dataframe to display. The ``table_df`` displays formatted data in the first 5 columns ("Characteristic", "Statistic", "F", "M", "All"). The ``table_df`` has additional columns that contain the statistics used for the statistics displayed in columns ["F", "M", "All"].

From above, ``gender_tbl.table_df`` is just a dataframe and can be combined with other ``table_df`` dataframes using ``pd.concat()`` to make a single ``table_df``.

.. code-block:: python

    table_df = pd.concat(
        [gender_tbl.table_df, age_tbl.table_df, bp_table.table_df]
     )

Show just the first 5 columns:

.. code-block:: python

    table_df.iloc[:, :5]


Like any dataframe, you can export to csv:

.. code-block:: python

    path = "my/path/to/csv/folder/table_df.csv"
    table_df.to_csv(path_or_buf=path, encoding="utf-8", index=0, sep="|")



.. |pypi| image:: https://img.shields.io/pypi/v/edc-analytics.svg
   :target: https://pypi.python.org/pypi/edc-analytics

.. |downloads| image:: https://pepy.tech/badge/edc-analytics
   :target: https://pepy.tech/project/edc-analytics

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clinicedc/edc-analytics",
    "name": "edc-analytics",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "django analytics pandas data collection clinicedc clinical trials",
    "author": "Erik van Widenfelt",
    "author_email": "ew2789@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/74/46/a872304e978a10b1b4e2430c88319d8afdf4200832555c64f5b9c5505518/edc_analytics-0.1.3.tar.gz",
    "platform": null,
    "description": "|pypi| |downloads|\n\n\nedc-analytics\n-------------\n\nBuild analytic tables from EDC data\n\n\nRead your data into a dataframe, for example an EDC screening table:\n\n.. code-block:: python\n\n    qs_screening = SubjectScreening.objects.all()\n    df = read_frame(qs_screening)\n\n\nConvert all numerics to ``pandas`` numerics:\n\n.. code-block:: python\n\n    cols = [\n        \"age_in_years\",\n        \"dia_blood_pressure_avg\",\n        \"fbg_value\",\n        \"hba1c_value\",\n        \"ogtt_value\",\n        \"sys_blood_pressure_avg\",\n    ]\n    df[cols] = df[cols].apply(pd.to_numeric)\n\n\nPass the dataframe to each ``Table`` class\n\n.. code-block:: python\n\n    gender_tbl = GenderTable(main_df=df)\n    age_tbl = AgeTable(main_df=df)\n    bp_table = BpTable(main_df=df)\n\n\nIn the ``Table`` instance,\n\n* ``data_df`` is the supporting dataframe\n* ``table_df`` is the dataframe to display. The ``table_df`` displays formatted data in the first 5 columns (\"Characteristic\", \"Statistic\", \"F\", \"M\", \"All\"). The ``table_df`` has additional columns that contain the statistics used for the statistics displayed in columns [\"F\", \"M\", \"All\"].\n\nFrom above, ``gender_tbl.table_df`` is just a dataframe and can be combined with other ``table_df`` dataframes using ``pd.concat()`` to make a single ``table_df``.\n\n.. code-block:: python\n\n    table_df = pd.concat(\n        [gender_tbl.table_df, age_tbl.table_df, bp_table.table_df]\n     )\n\nShow just the first 5 columns:\n\n.. code-block:: python\n\n    table_df.iloc[:, :5]\n\n\nLike any dataframe, you can export to csv:\n\n.. code-block:: python\n\n    path = \"my/path/to/csv/folder/table_df.csv\"\n    table_df.to_csv(path_or_buf=path, encoding=\"utf-8\", index=0, sep=\"|\")\n\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/edc-analytics.svg\n   :target: https://pypi.python.org/pypi/edc-analytics\n\n.. |downloads| image:: https://pepy.tech/badge/edc-analytics\n   :target: https://pepy.tech/project/edc-analytics\n",
    "bugtrack_url": null,
    "license": "GPL license, see LICENSE",
    "summary": "Build analytical tables for clinicedc/edc projects",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/clinicedc/edc-analytics"
    },
    "split_keywords": [
        "django",
        "analytics",
        "pandas",
        "data",
        "collection",
        "clinicedc",
        "clinical",
        "trials"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d5f3f78d6ce9059ecd667a238d131e498206a23132698f6d6d06dc36c5ede07",
                "md5": "ae7b5577ce15d644d0a112c4e53f1d23",
                "sha256": "aa9cd1c73e160aa5ec4b0a229e43d06a40b5e7995fd93e303366c009cce190bc"
            },
            "downloads": -1,
            "filename": "edc_analytics-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ae7b5577ce15d644d0a112c4e53f1d23",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 31535,
            "upload_time": "2024-10-09T16:31:59",
            "upload_time_iso_8601": "2024-10-09T16:31:59.903606Z",
            "url": "https://files.pythonhosted.org/packages/6d/5f/3f78d6ce9059ecd667a238d131e498206a23132698f6d6d06dc36c5ede07/edc_analytics-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7446a872304e978a10b1b4e2430c88319d8afdf4200832555c64f5b9c5505518",
                "md5": "efe3b6d58f5ee7f9934acd9ea221b25a",
                "sha256": "1861df43a7e6f7110170c2046ae30b96e5ed450a09cab645427b5dd2c0f38f5f"
            },
            "downloads": -1,
            "filename": "edc_analytics-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "efe3b6d58f5ee7f9934acd9ea221b25a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 27395,
            "upload_time": "2024-10-09T16:32:00",
            "upload_time_iso_8601": "2024-10-09T16:32:00.906359Z",
            "url": "https://files.pythonhosted.org/packages/74/46/a872304e978a10b1b4e2430c88319d8afdf4200832555c64f5b9c5505518/edc_analytics-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-09 16:32:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clinicedc",
    "github_project": "edc-analytics",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "edc-analytics"
}
        
Elapsed time: 0.36052s