Skip to content

Commit

Permalink
Merge pull request #904 from cal-itp/update_starterkit
Browse files Browse the repository at this point in the history
Update starterkit
  • Loading branch information
amandaha8 authored Sep 28, 2023
2 parents d0de40e + af27ca1 commit 3273982
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 33 deletions.
16 changes: 8 additions & 8 deletions _shared_utils/shared_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
from . import (
calitp_color_palette,
#calitp_color_palette,
dask_utils,
geography_utils,
#geography_utils,
gtfs_utils,
gtfs_utils_v2,
portfolio_utils,
rt_dates,
rt_utils,
schedule_rt_utils,
styleguide,
utils,
#styleguide,
#utils,
)

__all__ = [
"calitp_color_palette",
#"calitp_color_palette",
"dask_utils",
"geography_utils",
#"geography_utils",
"gtfs_utils",
"gtfs_utils_v2",
"portfolio_utils",
"schedule_rt_utils",
"rt_dates",
"rt_utils",
"styleguide",
"utils",
#"styleguide",
#"utils",
]
99 changes: 99 additions & 0 deletions ah_starterkit/testing_calitp.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "ff67558c-867f-45d0-94fd-ea6c75f56a61",
"metadata": {},
"outputs": [],
"source": [
"import geopandas as gpd\n",
"import pandas as pd\n",
"\n",
"# Hint: if this doesn't import: refer to docs for correctly import\n",
"# cd into _shared_utils folder, run the make setup_env command"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "403c09a4-a798-4bf6-a46c-502517d632e9",
"metadata": {},
"outputs": [],
"source": [
"my_gdf = pd.read_csv('gs://calitp-analytics-data/data-analyses/csuyat_folder/stops_caltrain_merced.csv')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "3154ca2e-0845-44c0-be95-377cd979eb93",
"metadata": {},
"outputs": [],
"source": [
"my_gdf2 = my_gdf.head()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "3160ecf0-3c52-4e70-99e2-34f6ce9f8905",
"metadata": {},
"outputs": [],
"source": [
"from calitp_data_analysis import geography_utils, utils"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "e0f92cce-cd64-414e-95d9-7e223434040a",
"metadata": {},
"outputs": [],
"source": [
"stops_ptg = geography_utils.create_point_geometry(\n",
" my_gdf2,\n",
" 'stop_lon',\n",
" 'stop_lat',\n",
" crs = 'EPSG:2229'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "f4e0d3a3-ad9d-47f7-a36a-b179c83f81af",
"metadata": {},
"outputs": [],
"source": [
"utils.geojson_gcs_export(\n",
" stops_ptg,\n",
" 'gs://calitp-analytics-data/data-analyses/project_list',\n",
" \"my-testgeojson.geojson\",\n",
" geojson_type = \"geojson\",\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
3 changes: 1 addition & 2 deletions starter_kit/basics_04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@
"metadata": {},
"source": [
"## Turn lat/lon into point geometry\n",
"\n",
"* There is a [function in shared_utils](https://github.com/cal-itp/data-analyses/blob/main/_shared_utils/shared_utils/geography_utils.py#L170-L192) that does it. Show the steps within the function (the long way), and also create the `geometry` column using `shared_utils`.\n",
"* There is a [function in calitp_data_analysis](https://github.com/cal-itp/data-infra/blob/main/packages/calitp-data-analysis/calitp_data_analysis/geography_utils.py#L57-L84) that does it. Show the steps within the function (the long way), and also create the `geometry` column using `shared_utils`.\n",
"* Use `geography_utils.create_point_geometry??` to see what goes into that function, and what that function looks like under the hood."
]
},
Expand Down
11 changes: 2 additions & 9 deletions starter_kit/basics_04_steps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"\n",
"from calitp_data_analysis.tables import tbls\n",
"from calitp_data_analysis.sql import query_sql\n",
"\n",
"from siuba import *"
]
},
Expand Down Expand Up @@ -123,18 +124,10 @@
"source": [
"## Turn lat/lon into point geometry\n",
"\n",
"* There is a [function in shared_utils](https://github.com/cal-itp/data-analyses/blob/main/_shared_utils/shared_utils/geography_utils.py#L170-L192) that does it. Show the steps within the function (the long way), and also create the `geometry` column using `shared_utils`.\n",
"* There is a [function in calitp_data_analysis](https://github.com/cal-itp/data-infra/blob/main/packages/calitp-data-analysis/calitp_data_analysis/geography_utils.py#L57-L84) that does it. Show the steps within the function (the long way), and also create the `geometry` column using `shared_utils`.\n",
"* Use `geography_utils.create_point_geometry??` to see what goes into that function, and what that function looks like under the hood."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6c845296-73bc-4a82-9e4a-5e88f2343f4c",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "8a21eac3-ac67-47d8-b4c8-694192fdd796",
Expand Down
4 changes: 2 additions & 2 deletions starter_kit/basics_05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@
"outputs": [],
"source": [
"# To add styleguide\n",
"from shared_utils import styleguide\n",
"from shared_utils import calitp_color_palette as cp"
"from calitp_data_analysis import styleguide\n",
"from calitp_data_analysis import calitp_color_palette as cp"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions starter_kit/basics_05_steps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@
"outputs": [],
"source": [
"# To add styleguide\n",
"from shared_utils import styleguide\n",
"from shared_utils import calitp_color_palette as cp"
"from calitp_data_analysis import styleguide\n",
"from calitp_data_analysis import calitp_color_palette as cp"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion starter_kit/basics_06.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"\n",
"# Hint: if this doesn't import: refer to docs for correctly import\n",
"# cd into _shared_utils folder, run the make setup_env command\n",
"import shared_utils"
"from calitp_data_analysis import geography_utils"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion starter_kit/data_sampling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"import geopandas as gpd\n",
"import numpy as np\n",
"import pandas as pd\n",
"import shared_utils\n",
"from shared_utils import gtfs_utils_v2\n",
"from calitp_data_analysis.sql import to_snakecase"
]
},
Expand Down
10 changes: 5 additions & 5 deletions starter_kit/shared_utils_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"from calitp_data_analysis.tables import tbls\n",
"from siuba import *\n",
"\n",
"from calitp_data_analysis import geography_utils\n",
"from shared_utils import geography_utils, utils"
]
},
Expand Down Expand Up @@ -621,8 +622,7 @@
"import pandas as pd\n",
"import seaborn as sns\n",
"\n",
"from shared_utils import geography_utils, styleguide\n",
"from shared_utils import calitp_color_palette as cp"
"from calitp_data_analysis import geography_utils,styleguide, calitp_color_palette as cp"
]
},
{
Expand Down Expand Up @@ -983,7 +983,7 @@
"import geopandas as gpd\n",
"import pandas as pd\n",
"\n",
"import shared_utils "
"from calitp_data_analysis import geography_utils"
]
},
{
Expand Down Expand Up @@ -1132,7 +1132,7 @@
}
],
"source": [
"shared_utils.geography_utils.CA_NAD83Albers"
"geography_utils.CA_NAD83Albers"
]
},
{
Expand Down Expand Up @@ -1160,7 +1160,7 @@
],
"source": [
"print(f\"original CRS: {gdf.crs}\")\n",
"gdf = gdf.to_crs(shared_utils.geography_utils.CA_StatePlane)\n",
"gdf = gdf.to_crs(geography_utils.CA_StatePlane)\n",
"print(f\"new CRS: {gdf.crs}\")"
]
},
Expand Down
6 changes: 3 additions & 3 deletions starter_kit/style-guide-examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"from IPython.display import Markdown\n",
"from plotnine import *\n",
"\n",
"from shared_utils import geography_utils, styleguide\n",
"from shared_utils import calitp_color_palette as cp "
"from calitp_data_analysis import geography_utils, styleguide\n",
"from calitp_data_analysis import calitp_color_palette as cp "
]
},
{
Expand Down Expand Up @@ -614,7 +614,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 3273982

Please sign in to comment.