Skip to content

Commit

Permalink
Add utils.checks.py: Check for common issues with function inputs #86
Browse files Browse the repository at this point in the history
  • Loading branch information
mdancho84 committed Oct 5, 2023
1 parent 967d0ac commit bf809eb
Show file tree
Hide file tree
Showing 78 changed files with 2,994 additions and 985 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added docs/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"hash": "f67ba1a2adfc794cdce793a18949cc40",
"hash": "2f2ffbe619aadc4e265ba920bfb7b9b6",
"result": {
"markdown": "---\ntitle: Install\ntoc: true\ntoc-depth: 3\nnumber-sections: true\nnumber-depth: 2\n---\n\n<!-- ::: {.callout-warning collapse=\"false\"}\n## Under Development\n\nThis library is currently under development and is not intended for general usage yet. Functionality is experimental until release 0.1.0. \n::: -->\n\n# Quick Install\n\nLet's get you up and running with `pytimetk` fast with the latest stable release. \n\n```bash\npip install pytimetk\n```\n\nYou can install from GitHub with this code. \n\n```bash\npip install git+https://github.com/business-science/pytimetk.git\n```\n\n# Next steps\n\nCheck out the [Quick Start Guide Next.](/getting-started/02_quick_start.html)\n\n# More Coming Soon...\n\nWe are in the early stages of development. But it's obvious the potential for `pytimetk` now in Python. 🐍\n\n- Please [⭐ us on GitHub](https://github.com/business-science/pytimetk) (it takes 2-seconds and means a lot). \n- To make requests, please see our [Project Roadmap GH Issue #2](https://github.com/business-science/pytimetk/issues/2). You can make requests there. \n- Want to contribute? [See our contributing guide here.](/contributing.html) \n\n",
"supporting": [
"01_installation_files\\figure-html"
"01_installation_files/figure-html"
],
"filters": [],
"includes": {}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"hash": "2ed693dfd96efb6f1921eb696a64d9ee",
"hash": "92fd719798ef778f3a372013aeba4e79",
"result": {
"markdown": "---\ntitle: Pandas Frequencies\ntoc: true\ntoc-depth: 3\nnumber-sections: true\nnumber-depth: 2\n---\n\n::: {.callout-note collapse=\"false\"}\n## How this guide benefits you\n\nThis guide covers how to use the `pandas` frequency strings within `pytimetk`. Once you understand key frequencies, you can apply them to manipulate time series data like a pro. \n:::\n\n# Pandas Frequencies\n\nPandas offers a variety of frequency strings, also known as offset aliases, to define the frequency of a time series. Here are some common frequency strings used in pandas:\n\n1. **'B'**: Business Day\n2. **'D'**: Calendar day\n3. **'W'**: Weekly\n4. **'M'**: Month end\n5. **'BM'**: Business month end\n6. **'MS'**: Month start\n7. **'BMS'**: Business month start\n8. **'Q'**: Quarter end\n9. **'BQ'**: Business quarter end\n10. **'QS'**: Quarter start\n11. **'BQS'**: Business quarter start\n12. **'A' or 'Y'**: Year end\n13. **'BA' or 'BY'**: Business year end\n14. **'AS' or 'YS'**: Year start\n15. **'BAS' or 'BYS'**: Business year start\n16. **'H'**: Hourly\n17. **'T' or 'min'**: Minutely\n18. **'S'**: Secondly\n19. **'L' or 'ms'**: Milliseconds\n20. **'U'**: Microseconds\n21. **'N'**: Nanoseconds\n\n### Custom Frequencies:\n- You can also create custom frequencies by combining base frequencies, like:\n - **'2D'**: Every 2 days\n - **'3W'**: Every 3 weeks\n - **'4H'**: Every 4 hours\n - **'1H30T'**: Every 1 hour and 30 minutes\n\n### Compound Frequencies:\n- You can combine multiple frequencies by adding them together.\n - **'1D1H'**: 1 day and 1 hour\n - **'1H30T'**: 1 hour and 30 minutes\n\n### Example:\n\n::: {.cell execution_count=1}\n``` {.python .cell-code}\nimport pandas as pd\n\n# Creating a date range with daily frequency\ndate_range_daily = pd.date_range(start='2023-01-01', end='2023-01-10', freq='D')\n\ndate_range_daily\n```\n\n::: {.cell-output .cell-output-display execution_count=1}\n```\nDatetimeIndex(['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04',\n '2023-01-05', '2023-01-06', '2023-01-07', '2023-01-08',\n '2023-01-09', '2023-01-10'],\n dtype='datetime64[ns]', freq='D')\n```\n:::\n:::\n\n\n::: {.cell execution_count=2}\n``` {.python .cell-code}\n# Creating a date range with 2 days frequency\ndate_range_two_days = pd.date_range(start='2023-01-01', end='2023-01-10', freq='2D')\n\ndate_range_two_days\n```\n\n::: {.cell-output .cell-output-display execution_count=2}\n```\nDatetimeIndex(['2023-01-01', '2023-01-03', '2023-01-05', '2023-01-07',\n '2023-01-09'],\n dtype='datetime64[ns]', freq='2D')\n```\n:::\n:::\n\n\nThese frequency strings help in resampling, creating date ranges, and handling time-series data efficiently in pandas.\n\n# Timetk Incorporates Pandas Frequencies\n\nNow that you've seen pandas frequencies, you'll see them pop up in many of the `pytimetk` functions. \n\n### Example: Padding Dates\n\nThis example shows how to use Pandas frequencies inside of `pytimetk` functions. \n\nWe'll use `pad_by_time` to show how to use freq to fill in missing dates. \n\n::: {.cell execution_count=3}\n``` {.python .cell-code}\n# DataFrame with missing dates\nimport pandas as pd\n\ndata = {\n # '2023-09-05' is missing\n 'datetime': ['2023-09-01', '2023-09-02', '2023-09-03', '2023-09-04', '2023-09-06'], \n 'value': [10, 30, 40, 50, 60]\n}\n\ndf = pd.DataFrame(data)\ndf['datetime'] = pd.to_datetime(df['datetime'])\ndf\n```\n\n::: {.cell-output .cell-output-display execution_count=3}\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>datetime</th>\n <th>value</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>2023-09-01</td>\n <td>10</td>\n </tr>\n <tr>\n <th>1</th>\n <td>2023-09-02</td>\n <td>30</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2023-09-03</td>\n <td>40</td>\n </tr>\n <tr>\n <th>3</th>\n <td>2023-09-04</td>\n <td>50</td>\n </tr>\n <tr>\n <th>4</th>\n <td>2023-09-06</td>\n <td>60</td>\n </tr>\n </tbody>\n</table>\n</div>\n```\n:::\n:::\n\n\nWe can resample to fill in the missing day using `pad_by_time` with `freq = 'D'`.\n\n::: {.cell execution_count=4}\n``` {.python .cell-code}\nimport pytimetk as tk\n\ndf.pad_by_time('datetime', freq = 'D')\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>datetime</th>\n <th>value</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>2023-09-01</td>\n <td>10.0</td>\n </tr>\n <tr>\n <th>1</th>\n <td>2023-09-02</td>\n <td>30.0</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2023-09-03</td>\n <td>40.0</td>\n </tr>\n <tr>\n <th>3</th>\n <td>2023-09-04</td>\n <td>50.0</td>\n </tr>\n <tr>\n <th>4</th>\n <td>2023-09-05</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>5</th>\n <td>2023-09-06</td>\n <td>60.0</td>\n </tr>\n </tbody>\n</table>\n</div>\n```\n:::\n:::\n\n\nWhat about resampling every 12 hours? Just set `freq = '12H'.\n\n::: {.cell execution_count=5}\n``` {.python .cell-code}\nimport pytimetk as tk\n\ndf.pad_by_time('datetime', freq = '12H')\n```\n\n::: {.cell-output .cell-output-display execution_count=5}\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>datetime</th>\n <th>value</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>2023-09-01 00:00:00</td>\n <td>10.0</td>\n </tr>\n <tr>\n <th>1</th>\n <td>2023-09-01 12:00:00</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2023-09-02 00:00:00</td>\n <td>30.0</td>\n </tr>\n <tr>\n <th>3</th>\n <td>2023-09-02 12:00:00</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>4</th>\n <td>2023-09-03 00:00:00</td>\n <td>40.0</td>\n </tr>\n <tr>\n <th>5</th>\n <td>2023-09-03 12:00:00</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>6</th>\n <td>2023-09-04 00:00:00</td>\n <td>50.0</td>\n </tr>\n <tr>\n <th>7</th>\n <td>2023-09-04 12:00:00</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>8</th>\n <td>2023-09-05 00:00:00</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>9</th>\n <td>2023-09-05 12:00:00</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>10</th>\n <td>2023-09-06 00:00:00</td>\n <td>60.0</td>\n </tr>\n </tbody>\n</table>\n</div>\n```\n:::\n:::\n\n\nYou'll see these pandas frequencies come up as the parameter `freq` in many `pytimetk` functions. \n\n# Next Steps\n\nCheck out the [Data Wrangling Guide next.](/guides/04_wrangling.html)\n\n# More Coming Soon...\n\nWe are in the early stages of development. But it's obvious the potential for `pytimetk` now in Python. 🐍\n\n- Please [⭐ us on GitHub](https://github.com/business-science/pytimetk) (it takes 2-seconds and means a lot). \n- To make requests, please see our [Project Roadmap GH Issue #2](https://github.com/business-science/pytimetk/issues/2). You can make requests there. \n- Want to contribute? [See our contributing guide here.](/contributing.html) \n\n",
"supporting": [
"03_pandas_frequency_files\\figure-html"
"03_pandas_frequency_files/figure-html"
],
"filters": [],
"includes": {
Expand Down
4 changes: 2 additions & 2 deletions docs/_freeze/guides/04_wrangling/execute-results/html.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/_freeze/guides/05_augmenting/execute-results/html.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/_freeze/index/execute-results/html.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit bf809eb

Please sign in to comment.