netCBS


NamenetCBS JSON
Version 0.0.0 PyPI version JSON
download
home_pageNone
SummaryPackage to create aggregated variables from CBS network data (POPNET)
upload_time2024-10-09 11:23:54
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 ODISSEI's Social Data Science (SoDa) team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords popnet cbs network data netcbs
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # netCBS
Package to efficiently create network measures using CBS networks (POPNET) in the RA. For example you may be interested in calculating the average income of the parents of the classmates of a student. This package allows you to do this in a fast and efficient way.

## Installation

```bash
pip install git+https://git@github.com/sodascience/netcbs.git@main
```

## Usage

See [notebook](tutorial_netCBS.ipynb) for accessible information and examples.


### Create network measures (e.g. the average income and age of the parents (link type 301) of the classmates of children in the sample)
```python
query =  "[Income, Age] -> Family[301] -> Schoolmates[all] -> Sample"
df = netcbs.transform(query, 
                     df_sample = df_sample,  # dataset with the sample to study
                     df_agg = df_agg, # dataset with the income variable
                     year=2021, # year to study
                     cbsdata_path='G:/Bevolking', # path to the CBS data
                     agg_funcs=[pl.mean, pl.sum, pl.count], # calculate the average
                     return_pandas=False, # returns a pandas dataframe instead of a polars dataframe
                     lazy=True # use polars lazy evaluation (faster/less memory usage)
                     )

```

## How does the library work?
### Query system
The library uses a query system to specify the relationships between the main sample dataframe and the context data. The query consists of a series of context types separated by arrows (->), with optional relationship types in square brackets. For example, the query `"[Income] -> Family[301] -> Schoolmates[all] -> Sample"` specifies that the income of the parents of the student's classmates should be calculated based on the provided sample dataframe.

### Data used:
The library checks the latest verion of each network file for the year specified in the `transform` function. 

The library removes duplicate entries from the df_sample and df_agg dataframes, and converts them to polars for efficient.

### Transformation fo the query
The `validate_query` function (called automatically by the `transform` function) ensures that the query string is correctly formatted and that all necessary columns are present in the input dataframes. It splits the query into individual contexts and verifies each part, raising errors for any issues found.

The different network files (contexts) are merged (inner join) consecutively based on the relationship columns specified in the query. The resulting dataframe is then aggregated based on the aggregation function (e.g., pl.mean, pl.sum) specified in the `transform` function.

We recommend to use the polars lazy evaluation (lazy=True) to reduce memory usage and speed up the calculations. For debugging this can be disabled by setting lazy=False.


## Contributing
Contributions are what make the open source community an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

Please refer to the [CONTRIBUTING](https://github.com/sodascience/netcbs/blob/main/CONTRIBUTING.md) file for more information on issues and pull requests.

## License and citation

The package `netCBS` is published under an MIT license. When using `netCBS` for academic work, please cite:
```
    TODO
```

## Contact

This project is developed and maintained by the [ODISSEI Social Data
Science (SoDa)](https://odissei-data.nl/nl/soda/) team.

<img src="soda_logo.png" alt="SoDa logo" width="250px"/>

Do you have questions, suggestions, or remarks? File an issue in the issue
tracker or feel free to contact the team via
https://odissei-data.nl/en/using-soda/.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "netCBS",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "popnet, cbs, network data, netCBS",
    "author": null,
    "author_email": "Javier Garcia-Bernardo <j.garciabernardo@uu.nl>",
    "download_url": "https://files.pythonhosted.org/packages/0b/da/826785ad2c42a0e066984b6f8640131c990fe900c871d3bb7debd5d3c586/netcbs-0.0.0.tar.gz",
    "platform": null,
    "description": "# netCBS\nPackage to efficiently create network measures using CBS networks (POPNET) in the RA. For example you may be interested in calculating the average income of the parents of the classmates of a student. This package allows you to do this in a fast and efficient way.\n\n## Installation\n\n```bash\npip install git+https://git@github.com/sodascience/netcbs.git@main\n```\n\n## Usage\n\nSee [notebook](tutorial_netCBS.ipynb) for accessible information and examples.\n\n\n### Create network measures (e.g. the average income and age of the parents (link type 301) of the classmates of children in the sample)\n```python\nquery =  \"[Income, Age] -> Family[301] -> Schoolmates[all] -> Sample\"\ndf = netcbs.transform(query, \n                     df_sample = df_sample,  # dataset with the sample to study\n                     df_agg = df_agg, # dataset with the income variable\n                     year=2021, # year to study\n                     cbsdata_path='G:/Bevolking', # path to the CBS data\n                     agg_funcs=[pl.mean, pl.sum, pl.count], # calculate the average\n                     return_pandas=False, # returns a pandas dataframe instead of a polars dataframe\n                     lazy=True # use polars lazy evaluation (faster/less memory usage)\n                     )\n\n```\n\n## How does the library work?\n### Query system\nThe library uses a query system to specify the relationships between the main sample dataframe and the context data. The query consists of a series of context types separated by arrows (->), with optional relationship types in square brackets. For example, the query `\"[Income] -> Family[301] -> Schoolmates[all] -> Sample\"` specifies that the income of the parents of the student's classmates should be calculated based on the provided sample dataframe.\n\n### Data used:\nThe library checks the latest verion of each network file for the year specified in the `transform` function. \n\nThe library removes duplicate entries from the df_sample and df_agg dataframes, and converts them to polars for efficient.\n\n### Transformation fo the query\nThe `validate_query` function (called automatically by the `transform` function) ensures that the query string is correctly formatted and that all necessary columns are present in the input dataframes. It splits the query into individual contexts and verifies each part, raising errors for any issues found.\n\nThe different network files (contexts) are merged (inner join) consecutively based on the relationship columns specified in the query. The resulting dataframe is then aggregated based on the aggregation function (e.g., pl.mean, pl.sum) specified in the `transform` function.\n\nWe recommend to use the polars lazy evaluation (lazy=True) to reduce memory usage and speed up the calculations. For debugging this can be disabled by setting lazy=False.\n\n\n## Contributing\nContributions are what make the open source community an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nPlease refer to the [CONTRIBUTING](https://github.com/sodascience/netcbs/blob/main/CONTRIBUTING.md) file for more information on issues and pull requests.\n\n## License and citation\n\nThe package `netCBS` is published under an MIT license. When using `netCBS` for academic work, please cite:\n```\n    TODO\n```\n\n## Contact\n\nThis project is developed and maintained by the [ODISSEI Social Data\nScience (SoDa)](https://odissei-data.nl/nl/soda/) team.\n\n<img src=\"soda_logo.png\" alt=\"SoDa logo\" width=\"250px\"/>\n\nDo you have questions, suggestions, or remarks? File an issue in the issue\ntracker or feel free to contact the team via\nhttps://odissei-data.nl/en/using-soda/.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 ODISSEI's Social Data Science (SoDa) team  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Package to create aggregated variables from CBS network data (POPNET)",
    "version": "0.0.0",
    "project_urls": {
        "homepage": "https://github.com/sodascience/netcbs",
        "repository": "https://github.com/sodascience/netcbs"
    },
    "split_keywords": [
        "popnet",
        " cbs",
        " network data",
        " netcbs"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3cf46ec6086efe08fa91b13fa7525f92d741cfa5d6aad49c695490b5f0ed0d4b",
                "md5": "573f3aa98ba47abb4f8a23b5f0419d59",
                "sha256": "2e69770d4368dcb3dd603bc9bc4bd3891a112644aa46c386a5d755814fb93c7b"
            },
            "downloads": -1,
            "filename": "netCBS-0.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "573f3aa98ba47abb4f8a23b5f0419d59",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9795,
            "upload_time": "2024-10-09T11:23:52",
            "upload_time_iso_8601": "2024-10-09T11:23:52.979663Z",
            "url": "https://files.pythonhosted.org/packages/3c/f4/6ec6086efe08fa91b13fa7525f92d741cfa5d6aad49c695490b5f0ed0d4b/netCBS-0.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0bda826785ad2c42a0e066984b6f8640131c990fe900c871d3bb7debd5d3c586",
                "md5": "ede64dc5c574bc5728b02054e5758f0b",
                "sha256": "2a02afa60f088848103bf1e7d861f8b7683adeb203bacde72669d7885ee196fe"
            },
            "downloads": -1,
            "filename": "netcbs-0.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ede64dc5c574bc5728b02054e5758f0b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8838,
            "upload_time": "2024-10-09T11:23:54",
            "upload_time_iso_8601": "2024-10-09T11:23:54.724685Z",
            "url": "https://files.pythonhosted.org/packages/0b/da/826785ad2c42a0e066984b6f8640131c990fe900c871d3bb7debd5d3c586/netcbs-0.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-09 11:23:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sodascience",
    "github_project": "netcbs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "netcbs"
}
        
Elapsed time: 0.38263s