Name | datespan JSON |
Version |
0.2.9
JSON |
| download |
home_page | https://github.com/Zeutschler/datespan |
Summary | Effortless date span parsing and management. |
upload_time | 2024-09-25 07:28:58 |
maintainer | None |
docs_url | None |
author | Thomas Zeutschler |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2024 Thomas Zeutschler 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 |
python
datetime
timespan
pandas
numpy
spark
data analysis
sql
dataframe
|
VCS |
|
bugtrack_url |
|
requirements |
python-dateutil
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# datespan
![GitHub license](https://img.shields.io/github/license/Zeutschler/datespan?color=A1C547)
![PyPI version](https://img.shields.io/pypi/v/datespan?logo=pypi&logoColor=979DA4&color=A1C547)
![PyPI Downloads](https://img.shields.io/pypi/dm/datespan.svg?logo=pypi&logoColor=979DA4&label=PyPI%20downloads&color=A1C547)
![GitHub last commit](https://img.shields.io/github/last-commit/Zeutschler/datespan?logo=github&logoColor=979DA4&color=A1C547)
![unit tests](https://img.shields.io/github/actions/workflow/status/zeutschler/datespan/python-package.yml?logo=GitHub&logoColor=979DA4&label=unit%20tests&color=A1C547)
![build](https://img.shields.io/github/actions/workflow/status/zeutschler/datespan/python-package.yml?logo=GitHub&logoColor=979DA4&color=A1C547)
-----------------
A Python package for effortless date span parsing and management.
Aimed for data analysis and processing, useful in any context requiring date & time spans.
```bash
pip install datespan
```
```python
import pandas as pd
from datespan import parse, DateSpan
df = pd.DataFrame({"date": pd.date_range("2024-01-01", "2024-12-31")})
dss = parse("April 2024 ytd") # Create a DateSpanSet, same as 'DateSpanSet("April 2024 ytd")'
dss.add("May") # Add full month May of the current year
dss.add("today") # Add the current day from 00:00 to 23:59:59
dss += "previous week" # Add a full week from Monday 00:00 to Sunday 23:59:59
dss -= "January" # Remove full month January of the current year
print(len(dss)) # returns the number of contained nonconsecutive DateSpans
print(dss.to_tuples()) # returns a list of (start, end) tuples representing the DateSpanSet
print(dss.to_sql("date")) # returns an SQL WHERE clause fragment
print(dss.filter(df, "date")) # returns a DataFrame filtered by the DateSpanSet on column 'date'
```
### Classes
`DateSpan` represents a single date or time span, defined by a start and an end datetime.
Provides methods to create, compare, merge, parse, split, shift, expand & intersect
`DateSpan` objects and /or `datetime`, `date`or `time` objects.
`DateSpanSet` represents an ordered and redundancy free collection of `DateSpan` objects,
where consecutive or overlapping `DateSpan` objects get automatically merged into a single `DateSpan`
object. Required for fragmented date span expressions like `every 2nd Friday of next month`.
`DateSpanParser` provides parsing for arbitrary date, time and date span strings in english language,
ranging from simple dates like '2021-01-01' up to complex date span expressions like
'Mondays to Wednesday last month'. For internal DateTime parsing and manipulation, the
[DateUtil]() library is used.
### Part of the CubedPandas Project
The 'dataspan' package has been carved out from the
[CubedPandas](https://github.com/Zeutschler/cubedpandas) project, a library for
easy, fast & fun data analysis with Pandas dataframes, as DataSpan serves a broader
scope and purpose and can be used independently of CubedPandas.
### Bugs, Issues, Feature Requests
Please report any bugs, issues, feature requests, questions or feedback on the
[GitHub Issues](https://github.com/Zeutschler/datespan/issues) page. It will
be highly appreciated and will help to improve the package.
### Documentation
Documentation will be available from 0.3.0 release on.
Raw data
{
"_id": null,
"home_page": "https://github.com/Zeutschler/datespan",
"name": "datespan",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Thomas Zeutschler <cubedpandas@gmail.com>",
"keywords": "python, datetime, timespan, pandas, numpy, spark, data analysis, sql, dataframe",
"author": "Thomas Zeutschler",
"author_email": "cubedpandas@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/13/b2/9f17bb1456093279fb9eb7c9ed0d156c930f7fde02ece9b5636bf94f14a8/datespan-0.2.9.tar.gz",
"platform": "any",
"description": "# datespan\n\n![GitHub license](https://img.shields.io/github/license/Zeutschler/datespan?color=A1C547)\n![PyPI version](https://img.shields.io/pypi/v/datespan?logo=pypi&logoColor=979DA4&color=A1C547)\n![PyPI Downloads](https://img.shields.io/pypi/dm/datespan.svg?logo=pypi&logoColor=979DA4&label=PyPI%20downloads&color=A1C547)\n![GitHub last commit](https://img.shields.io/github/last-commit/Zeutschler/datespan?logo=github&logoColor=979DA4&color=A1C547)\n![unit tests](https://img.shields.io/github/actions/workflow/status/zeutschler/datespan/python-package.yml?logo=GitHub&logoColor=979DA4&label=unit%20tests&color=A1C547)\n![build](https://img.shields.io/github/actions/workflow/status/zeutschler/datespan/python-package.yml?logo=GitHub&logoColor=979DA4&color=A1C547)\n\n\n-----------------\nA Python package for effortless date span parsing and management. \nAimed for data analysis and processing, useful in any context requiring date & time spans. \n\n```bash\npip install datespan\n```\n\n```python\nimport pandas as pd\nfrom datespan import parse, DateSpan\ndf = pd.DataFrame({\"date\": pd.date_range(\"2024-01-01\", \"2024-12-31\")})\n\ndss = parse(\"April 2024 ytd\") # Create a DateSpanSet, same as 'DateSpanSet(\"April 2024 ytd\")'\ndss.add(\"May\") # Add full month May of the current year\ndss.add(\"today\") # Add the current day from 00:00 to 23:59:59\ndss += \"previous week\" # Add a full week from Monday 00:00 to Sunday 23:59:59\ndss -= \"January\" # Remove full month January of the current year\n\nprint(len(dss)) # returns the number of contained nonconsecutive DateSpans\nprint(dss.to_tuples()) # returns a list of (start, end) tuples representing the DateSpanSet\nprint(dss.to_sql(\"date\")) # returns an SQL WHERE clause fragment\nprint(dss.filter(df, \"date\")) # returns a DataFrame filtered by the DateSpanSet on column 'date'\n```\n\n### Classes\n`DateSpan` represents a single date or time span, defined by a start and an end datetime. \nProvides methods to create, compare, merge, parse, split, shift, expand & intersect \n`DateSpan` objects and /or `datetime`, `date`or `time` objects.\n\n`DateSpanSet` represents an ordered and redundancy free collection of `DateSpan` objects, \nwhere consecutive or overlapping `DateSpan` objects get automatically merged into a single `DateSpan` \nobject. Required for fragmented date span expressions like `every 2nd Friday of next month`. \n\n`DateSpanParser` provides parsing for arbitrary date, time and date span strings in english language,\nranging from simple dates like '2021-01-01' up to complex date span expressions like \n'Mondays to Wednesday last month'. For internal DateTime parsing and manipulation, the \n[DateUtil]() library is used. \n\n### Part of the CubedPandas Project\nThe 'dataspan' package has been carved out from the \n[CubedPandas](https://github.com/Zeutschler/cubedpandas) project, a library for \neasy, fast & fun data analysis with Pandas dataframes, as DataSpan serves a broader \nscope and purpose and can be used independently of CubedPandas. \n\n### Bugs, Issues, Feature Requests\nPlease report any bugs, issues, feature requests, questions or feedback on the\n[GitHub Issues](https://github.com/Zeutschler/datespan/issues) page. It will\nbe highly appreciated and will help to improve the package.\n\n### Documentation\nDocumentation will be available from 0.3.0 release on. \n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Thomas Zeutschler 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": "Effortless date span parsing and management.",
"version": "0.2.9",
"project_urls": {
"Changelog": "https://github.com/Zeutschler/datespan/CHANGELOG.md",
"Documentation": "https://github.com/Zeutschler/datespan",
"Homepage": "https://github.com/Zeutschler/datespan",
"Issues": "https://github.com/Zeutschler/datespan/issues",
"Repository": "https://github.com/Zeutschler/datespan.git",
"pypi": "https://pypi.org/project/datespan/"
},
"split_keywords": [
"python",
" datetime",
" timespan",
" pandas",
" numpy",
" spark",
" data analysis",
" sql",
" dataframe"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d1410941ca59ca14c831c944c139d5c5cbbbd29e1938fb9740785bacff063bcd",
"md5": "4351a1a1097a2d9a54227da02394e41a",
"sha256": "e616b1c0ef27cb8af95f48a1e78f9182fbd44275bf300433ca37239e9e155fbd"
},
"downloads": -1,
"filename": "datespan-0.2.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4351a1a1097a2d9a54227da02394e41a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 45903,
"upload_time": "2024-09-25T07:28:56",
"upload_time_iso_8601": "2024-09-25T07:28:56.501704Z",
"url": "https://files.pythonhosted.org/packages/d1/41/0941ca59ca14c831c944c139d5c5cbbbd29e1938fb9740785bacff063bcd/datespan-0.2.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "13b29f17bb1456093279fb9eb7c9ed0d156c930f7fde02ece9b5636bf94f14a8",
"md5": "e182a5e0542325c2664973eb2484901e",
"sha256": "ed3f532eefd792cd9301b1b90c3e7f15d622051258cb215d9f502327656c5ec3"
},
"downloads": -1,
"filename": "datespan-0.2.9.tar.gz",
"has_sig": false,
"md5_digest": "e182a5e0542325c2664973eb2484901e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 42390,
"upload_time": "2024-09-25T07:28:58",
"upload_time_iso_8601": "2024-09-25T07:28:58.213244Z",
"url": "https://files.pythonhosted.org/packages/13/b2/9f17bb1456093279fb9eb7c9ed0d156c930f7fde02ece9b5636bf94f14a8/datespan-0.2.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-25 07:28:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Zeutschler",
"github_project": "datespan",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "python-dateutil",
"specs": []
}
],
"lcname": "datespan"
}