Skip to content

Commit

Permalink
adding contributors and maintainer references
Browse files Browse the repository at this point in the history
  • Loading branch information
NKeleher committed Jul 13, 2024
1 parent 0e7f739 commit 4ffa29d
Show file tree
Hide file tree
Showing 28 changed files with 502 additions and 19 deletions.
6 changes: 3 additions & 3 deletions _freeze/docs/software/python/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"hash": "d0290ef074488257c8582cf93d3a1c81",
"hash": "c09c2f1ec6ef532984c8530835b78811",
"result": {
"engine": "jupyter",
"markdown": "---\ntitle: Python\nexecute:\n eval: true\n---\n\n## What is Python?\n\nPython is a high-level, general-purpose programming language that is widely used in data\nscience, machine learning, and web development. It has a large standard library and a\nvibrant community that provides a wide range of libraries and tools for various\napplications. As such, Python provides a general-purpose ecosystem that can be used for\na wide range of applications.\n\n## How to install Python?\n\nThere are many ways to install Python. We recommend using Python in a virtual\nenvironment to avoid conflicts with other Python installations on your system.\n\nWe recommend using a [rye](https://rye.astral.sh/) or [pixi](https://pixi.sh/latest/).\nBoth of these tools provide a simple way to create and manage Python virtual\nenvironments.\n\nIn both cases, you can manage the python packages that are installed in the virtual\nenvironment using a `pyproject.toml` file. See the pyproject.toml example in this\nrepository for an example of how to manage Python packages. To add package dependencies\nto the virtual environment, using `rye`, you can run:\n\nWe'll use `rye` to demonstrate how to manage a Python virtual environment. Watch the\nfollowing video for a quick introduction to `rye`:\n\n{{\\< video https://youtu.be/q99TYA7LnuA >}}\n\nFirst, install `rye` using `winget` (Windows) or `brew` (MacOS/Linux):\n\n| Platform | Commands |\n| -------- | -------------------- |\n| Windows | `winget install rye` |\n| MacOS | `brew install rye` |\n| Linux | `brew install rye` |\n\nAdd libraries to the virtual environment using `rye add ...`:\n\n::: {#b90c8a05 .cell execution_count=1}\n``` {.python .cell-code}\n> rye add jupyterlab pandas matplotlib seaborn\n```\n:::\n\n\n## Coding Conventions\n\nWe highly recommend working with a [virtual environment](../guides/venv.md) to manage\nPython dependencies. The `pyproject.toml` is the preferred way to keep track of python\ndependencies as well as project-specific python conventions.\n\nWe recommend using [Ruff](https://docs.astral.sh/ruff/) to enforce\n[linting](<https://en.wikipedia.org/wiki/Lint_(software)>) and formatting rules. In most\ncases you can use the default linting and formatting rules provided by `ruff`. However,\nyou can customize the rules by modifying the `[tool.ruff]` section of the\n`pyproject.toml` file in the root of your project. for more about the configuration\noptions, see the [Ruff documentation](https://docs.astral.sh/ruff/configuration/).\n\nIf you are working in a virtual environment created by `rye`, you automatically have\naccess to `Ruff via `rye lint`and`rye fmt\\` commands to lint and format your code.\n\nFor more inspiration, see the\n[GitLab Data Team's Python Guide](https://handbook.gitlab.com/handbook/business-technology/data-team/platform/python-guide/)\nand [Google's Python Style Guide](https://google.github.io/styleguide/pyguide.html).\n\n## Example Usage\n\nLet's load an example World Bank data via [Gapminder](https://www.gapminder.org/) using\nthe [causaldata](https://github.com/NickCH-K/causaldata) package.\n\n::: {#faeff2b5 .cell execution_count=2}\n``` {.python .cell-code}\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport statsmodels.formula.api as sm\nfrom causaldata import gapminder\n```\n:::\n\n\nLoad the Gapminder data as a pandas DataFrame:\n\n::: {#51d3d753 .cell execution_count=3}\n``` {.python .cell-code}\ndf = gapminder.load_pandas().data\n```\n:::\n\n\nWe can check the dimensions of the DataFrame using `df.info()`:\n\n::: {#fc6a5331 .cell execution_count=4}\n``` {.python .cell-code}\ndf.info()\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n<class 'pandas.core.frame.DataFrame'>\nRangeIndex: 1704 entries, 0 to 1703\nData columns (total 6 columns):\n # Column Non-Null Count Dtype \n--- ------ -------------- ----- \n 0 country 1704 non-null object \n 1 continent 1704 non-null object \n 2 year 1704 non-null int64 \n 3 lifeExp 1704 non-null float64\n 4 pop 1704 non-null int64 \n 5 gdpPercap 1704 non-null float64\ndtypes: float64(2), int64(2), object(2)\nmemory usage: 80.0+ KB\n```\n:::\n:::\n\n\nLet's take a look at the first few rows of the DataFrame using `df.head()`:\n\n::: {#d2897874 .cell execution_count=5}\n``` {.python .cell-code}\ndf.head()\n```\n\n::: {.cell-output .cell-output-display execution_count=16}\n```{=html}\n<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>country</th>\n <th>continent</th>\n <th>year</th>\n <th>lifeExp</th>\n <th>pop</th>\n <th>gdpPercap</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1952</td>\n <td>28.801</td>\n <td>8425333</td>\n <td>779.445314</td>\n </tr>\n <tr>\n <th>1</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1957</td>\n <td>30.332</td>\n <td>9240934</td>\n <td>820.853030</td>\n </tr>\n <tr>\n <th>2</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1962</td>\n <td>31.997</td>\n <td>10267083</td>\n <td>853.100710</td>\n </tr>\n <tr>\n <th>3</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1967</td>\n <td>34.020</td>\n <td>11537966</td>\n <td>836.197138</td>\n </tr>\n <tr>\n <th>4</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1972</td>\n <td>36.088</td>\n <td>13079460</td>\n <td>739.981106</td>\n </tr>\n </tbody>\n</table>\n</div>\n```\n:::\n:::\n\n\nTake a look at the relationship between GDP per Capita and Life Expectancy:\n\n::: {#1c03acc5 .cell execution_count=6}\n``` {.python .cell-code}\nsns.scatterplot(x=\"gdpPercap\", y=\"lifeExp\", hue=\"continent\", data=df).set(\n xscale=\"log\", ylabel=\"Life Expectancy\", xlabel=\"GDP per Capita\"\n)\n```\n\n::: {.cell-output .cell-output-display}\n![](python_files/figure-html/cell-7-output-1.png){width=585 height=431}\n:::\n:::\n\n\nSeparate the data by year, focusing on 1957 and 2007:\n\n::: {#67ef360d .cell execution_count=7}\n``` {.python .cell-code}\nsns.relplot(\n data=df.where(df[\"year\"].isin([1957, 2007])),\n x=\"gdpPercap\",\n y=\"lifeExp\",\n col=\"year\",\n hue=\"continent\",\n col_wrap=1,\n kind=\"scatter\",\n palette=\"muted\",\n).set(xscale=\"log\", ylabel=\"Life Expectancy\", xlabel=\"GDP per Capita\")\n```\n\n::: {.cell-output .cell-output-display}\n![](python_files/figure-html/cell-8-output-1.png){width=575 height=952}\n:::\n:::\n\n\n## Learning Resources\n\n- [The Python Tutorial](https://docs.python.org/3.12/tutorial/index.html)\n- [Python Data Science Handbook](https://jakevdp.github.io/PythonDataScienceHandbook/)\n- [Efficient Python for Data Scientists](https://khuyentran1401.github.io/Efficient_Python_tricks_and_tools_for_data_scientists/README.html)\n- [The Hitchhiker's Guide to Python](https://docs.python-guide.org/)\n\n",
"markdown": "---\ntitle: Python\n# Editors are the \"Maintainers\" of the page\neditors:\n - \"[Niall Keleher](https://poverty-action.org/people/niall-keleher)\"\n\n# Authors are the \"Contributors\" of the page\n# Add your name to the list if you have contributed to this page\n# author:\n# - Niall Keleher\nexecute:\n eval: true\njupyter:\n jupytext:\n text_representation:\n extension: .qmd\n format_name: quarto\n format_version: '1.0'\n jupytext_version: 1.16.2\n kernelspec:\n display_name: Python 3 (ipykernel)\n language: python\n name: python3\n---\n\n\n\n\n## What is Python?\n\nPython is a high-level, general-purpose programming language that is widely used in data\nscience, machine learning, and web development. It has a large standard library and a\nvibrant community that provides a wide range of libraries and tools for various\napplications. As such, Python provides a general-purpose ecosystem that can be used for\na wide range of applications.\n\n## How to install Python?\n\nThere are many ways to install Python. We recommend using Python in a virtual\nenvironment to avoid conflicts with other Python installations on your system.\n\nWe recommend using a [rye](https://rye.astral.sh/) or [pixi](https://pixi.sh/latest/).\nBoth of these tools provide a simple way to create and manage Python virtual\nenvironments.\n\nIn both cases, you can manage the python packages that are installed in the virtual\nenvironment using a `pyproject.toml` file. See the pyproject.toml example in this\nrepository for an example of how to manage Python packages. To add package dependencies\nto the virtual environment, using `rye`, you can run:\n\nWe'll use `rye` to demonstrate how to manage a Python virtual environment. Watch the\nfollowing video for a quick introduction to `rye`:\n\n{{\\< video https://youtu.be/q99TYA7LnuA >}}\n\nFirst, install `rye` using `winget` (Windows) or `brew` (MacOS/Linux):\n\n| Platform | Commands |\n| -------- | -------------------- |\n| Windows | `winget install rye` |\n| MacOS | `brew install rye` |\n| Linux | `brew install rye` |\n\nAdd libraries to the virtual environment using `rye add ...`:\n\n::: {#0b9678c2 .cell execution_count=1}\n``` {.python .cell-code}\n> rye add jupyterlab pandas matplotlib seaborn\n```\n:::\n\n\n## Coding Conventions\n\nWe highly recommend working with a [virtual environment](../guides/venv.md) to manage\nPython dependencies. The `pyproject.toml` is the preferred way to keep track of python\ndependencies as well as project-specific python conventions.\n\nWe recommend using [Ruff](https://docs.astral.sh/ruff/) to enforce\n[linting](<https://en.wikipedia.org/wiki/Lint_(software)>) and formatting rules. In most\ncases you can use the default linting and formatting rules provided by `ruff`. However,\nyou can customize the rules by modifying the `[tool.ruff]` section of the\n`pyproject.toml` file in the root of your project. for more about the configuration\noptions, see the [Ruff documentation](https://docs.astral.sh/ruff/configuration/).\n\nIf you are working in a virtual environment created by `rye`, you automatically have\naccess to `Ruff via `rye lint`and`rye fmt\\` commands to lint and format your code.\n\nFor more inspiration, see the\n[GitLab Data Team's Python Guide](https://handbook.gitlab.com/handbook/business-technology/data-team/platform/python-guide/)\nand [Google's Python Style Guide](https://google.github.io/styleguide/pyguide.html).\n\n## Example Usage\n\nLet's load an example World Bank data via [Gapminder](https://www.gapminder.org/) using\nthe [causaldata](https://github.com/NickCH-K/causaldata) package.\n\n::: {#23edac86 .cell execution_count=2}\n``` {.python .cell-code}\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport statsmodels.formula.api as sm\nfrom causaldata import gapminder\n```\n:::\n\n\nLoad the Gapminder data as a pandas DataFrame:\n\n::: {#ec9292c0 .cell execution_count=3}\n``` {.python .cell-code}\ndf = gapminder.load_pandas().data\n```\n:::\n\n\nWe can check the dimensions of the DataFrame using `df.info()`:\n\n::: {#de42a732 .cell execution_count=4}\n``` {.python .cell-code}\ndf.info()\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n<class 'pandas.core.frame.DataFrame'>\nRangeIndex: 1704 entries, 0 to 1703\nData columns (total 6 columns):\n # Column Non-Null Count Dtype \n--- ------ -------------- ----- \n 0 country 1704 non-null object \n 1 continent 1704 non-null object \n 2 year 1704 non-null int64 \n 3 lifeExp 1704 non-null float64\n 4 pop 1704 non-null int64 \n 5 gdpPercap 1704 non-null float64\ndtypes: float64(2), int64(2), object(2)\nmemory usage: 80.0+ KB\n```\n:::\n:::\n\n\nLet's take a look at the first few rows of the DataFrame using `df.head()`:\n\n::: {#c5abbb6d .cell execution_count=5}\n``` {.python .cell-code}\ndf.head()\n```\n\n::: {.cell-output .cell-output-display execution_count=4}\n```{=html}\n<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>country</th>\n <th>continent</th>\n <th>year</th>\n <th>lifeExp</th>\n <th>pop</th>\n <th>gdpPercap</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1952</td>\n <td>28.801</td>\n <td>8425333</td>\n <td>779.445314</td>\n </tr>\n <tr>\n <th>1</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1957</td>\n <td>30.332</td>\n <td>9240934</td>\n <td>820.853030</td>\n </tr>\n <tr>\n <th>2</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1962</td>\n <td>31.997</td>\n <td>10267083</td>\n <td>853.100710</td>\n </tr>\n <tr>\n <th>3</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1967</td>\n <td>34.020</td>\n <td>11537966</td>\n <td>836.197138</td>\n </tr>\n <tr>\n <th>4</th>\n <td>Afghanistan</td>\n <td>Asia</td>\n <td>1972</td>\n <td>36.088</td>\n <td>13079460</td>\n <td>739.981106</td>\n </tr>\n </tbody>\n</table>\n</div>\n```\n:::\n:::\n\n\nTake a look at the relationship between GDP per Capita and Life Expectancy:\n\n::: {#abd5bd29 .cell execution_count=6}\n``` {.python .cell-code}\nsns.scatterplot(x=\"gdpPercap\", y=\"lifeExp\", hue=\"continent\", data=df).set(\n xscale=\"log\", ylabel=\"Life Expectancy\", xlabel=\"GDP per Capita\"\n)\n```\n\n::: {.cell-output .cell-output-display}\n![](python_files/figure-html/cell-7-output-1.png){width=585 height=431}\n:::\n:::\n\n\nSeparate the data by year, focusing on 1957 and 2007:\n\n::: {#0f7aec06 .cell execution_count=7}\n``` {.python .cell-code}\nsns.relplot(\n data=df.where(df[\"year\"].isin([1957, 2007])),\n x=\"gdpPercap\",\n y=\"lifeExp\",\n col=\"year\",\n hue=\"continent\",\n col_wrap=1,\n kind=\"scatter\",\n palette=\"muted\",\n).set(xscale=\"log\", ylabel=\"Life Expectancy\", xlabel=\"GDP per Capita\")\n```\n\n::: {.cell-output .cell-output-display}\n![](python_files/figure-html/cell-8-output-1.png){width=575 height=952}\n:::\n:::\n\n\n## Learning Resources\n\n- [The Python Tutorial](https://docs.python.org/3.12/tutorial/index.html)\n- [Python Data Science Handbook](https://jakevdp.github.io/PythonDataScienceHandbook/)\n- [Efficient Python for Data Scientists](https://khuyentran1401.github.io/Efficient_Python_tricks_and_tools_for_data_scientists/README.html)\n- [The Hitchhiker's Guide to Python](https://docs.python-guide.org/)\n\n",
"supporting": [
"python_files"
"python_files\\figure-html"
],
"filters": [],
"includes": {
Expand Down
Loading

0 comments on commit 4ffa29d

Please sign in to comment.