Name | pandas-timeinterval JSON |
Version |
2024.6.3
JSON |
| download |
home_page | None |
Summary | A package to trim datetime indexed DataFrames and Series in pandas. |
upload_time | 2024-06-27 21:36:27 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | MIT License Copyright (c) 2024 jjrreett 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 |
pandas
datetime
intervals
dataframes
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pandas-timeinterval
A package to trim datetime-indexed DataFrames and Series in pandas. This package is useful for analyzing sparse DataFrames. It provides functionalities to generate Intervals objects using boolean Series, modify these Intervals using various methods (such as expand, contract), and combine them via set operations. The resulting Intervals can be used to trim any DataFrame using the `.trim` method.
## Features
- **Union and Intersection**: Perform union and intersection operations on interval objects.
- **Trim**: Trim DataFrame/Series to only include data within specified intervals.
- **Adjust**: Adjust intervals by a specified timedelta.
- **Normalize**: Merge overlapping intervals into a single interval.
- **Flexible Interval Creation**: Create intervals from boolean Series.
## Installation
```bash
pip install pandas-timeinterval
```
## Usage
## Union and Intersection Example
```python
import pandas as pd
from pandas_timeinterval import Intervals
# Create two Intervals objects with datetime ranges
intervals1 = Intervals([(pd.Timestamp("2024-01-01"), pd.Timestamp("2024-01-02"))])
intervals2 = Intervals([(pd.Timestamp("2024-01-03"), pd.Timestamp("2024-01-04"))])
# Perform union operation
union_intervals = intervals1.union(intervals2)
print(union_intervals)
# Perform intersection operation
intersection_intervals = intervals1.intersection(intervals2)
print(intersection_intervals)
```
### Trim Example
```python
import pandas as pd
from pandas_timeinterval import Intervals, Interval
# Create a sample DataFrame
sample_data = pd.Series(
[1, 2, 3, 4, 5], index=pd.date_range(start="2021-01-01", periods=5, freq="D")
)
# Create an Intervals object
intervals = Intervals([(pd.Timestamp("2021-01-02"), pd.Timestamp("2021-01-03"))])
# Trim the data
trimmed_data = intervals.trim(sample_data)
print(trimmed_data)
```
### Adjust Example
```python
import pandas as pd
from pandas_timeinterval import Intervals, Interval
# Create Intervals object
intervals = Intervals(
[Interval(pd.Timestamp("2021-01-01"), pd.Timestamp("2021-01-03")),
Interval(pd.Timestamp("2021-01-02"), pd.Timestamp("2021-01-04"))]
)
# Adjust intervals by adding one day
adjusted_intervals = intervals.adjust(pd.Timedelta(days=1))
print(adjusted_intervals)
# Normalize intervals to merge overlapping intervals
normalized_intervals = intervals.normalize()
print(normalized_intervals)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pandas-timeinterval",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "pandas, datetime, intervals, dataframes",
"author": null,
"author_email": "Jarrett Bullion <jjrreett@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f0/78/46520afda5dfbe49264458dfe9d17a03a4fcb517c6e931821b510518194d/pandas_timeinterval-2024.6.3.tar.gz",
"platform": null,
"description": "# pandas-timeinterval\n\nA package to trim datetime-indexed DataFrames and Series in pandas. This package is useful for analyzing sparse DataFrames. It provides functionalities to generate Intervals objects using boolean Series, modify these Intervals using various methods (such as expand, contract), and combine them via set operations. The resulting Intervals can be used to trim any DataFrame using the `.trim` method.\n\n## Features\n\n- **Union and Intersection**: Perform union and intersection operations on interval objects.\n- **Trim**: Trim DataFrame/Series to only include data within specified intervals.\n- **Adjust**: Adjust intervals by a specified timedelta.\n- **Normalize**: Merge overlapping intervals into a single interval.\n- **Flexible Interval Creation**: Create intervals from boolean Series.\n\n## Installation\n\n```bash\npip install pandas-timeinterval\n```\n\n## Usage\n\n## Union and Intersection Example\n```python\nimport pandas as pd\nfrom pandas_timeinterval import Intervals\n\n# Create two Intervals objects with datetime ranges\nintervals1 = Intervals([(pd.Timestamp(\"2024-01-01\"), pd.Timestamp(\"2024-01-02\"))])\nintervals2 = Intervals([(pd.Timestamp(\"2024-01-03\"), pd.Timestamp(\"2024-01-04\"))])\n\n# Perform union operation\nunion_intervals = intervals1.union(intervals2)\nprint(union_intervals)\n\n# Perform intersection operation\nintersection_intervals = intervals1.intersection(intervals2)\nprint(intersection_intervals)\n```\n\n### Trim Example\n\n```python\nimport pandas as pd\nfrom pandas_timeinterval import Intervals, Interval\n\n# Create a sample DataFrame\nsample_data = pd.Series(\n [1, 2, 3, 4, 5], index=pd.date_range(start=\"2021-01-01\", periods=5, freq=\"D\")\n)\n\n# Create an Intervals object\nintervals = Intervals([(pd.Timestamp(\"2021-01-02\"), pd.Timestamp(\"2021-01-03\"))])\n\n# Trim the data\ntrimmed_data = intervals.trim(sample_data)\n\nprint(trimmed_data)\n```\n\n### Adjust Example\n\n```python\nimport pandas as pd\nfrom pandas_timeinterval import Intervals, Interval\n\n# Create Intervals object\nintervals = Intervals(\n [Interval(pd.Timestamp(\"2021-01-01\"), pd.Timestamp(\"2021-01-03\")),\n Interval(pd.Timestamp(\"2021-01-02\"), pd.Timestamp(\"2021-01-04\"))]\n)\n\n# Adjust intervals by adding one day\nadjusted_intervals = intervals.adjust(pd.Timedelta(days=1))\nprint(adjusted_intervals)\n\n# Normalize intervals to merge overlapping intervals\nnormalized_intervals = intervals.normalize()\nprint(normalized_intervals)\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 jjrreett 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": "A package to trim datetime indexed DataFrames and Series in pandas.",
"version": "2024.6.3",
"project_urls": {
"Homepage": "https://github.com/jjrreett/pandas-timeinterval"
},
"split_keywords": [
"pandas",
" datetime",
" intervals",
" dataframes"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eb0e2618bd3213a8e04b6feb076397383b8071916fbfd925ae803e012133bf75",
"md5": "aef7cecefeb4436cb3b178fb5f790d4a",
"sha256": "88e56365b915036e4e80bc62182c1fef55fe3a3aa37dd1009f15310a3a60e383"
},
"downloads": -1,
"filename": "pandas_timeinterval-2024.6.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "aef7cecefeb4436cb3b178fb5f790d4a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7874,
"upload_time": "2024-06-27T21:36:26",
"upload_time_iso_8601": "2024-06-27T21:36:26.377147Z",
"url": "https://files.pythonhosted.org/packages/eb/0e/2618bd3213a8e04b6feb076397383b8071916fbfd925ae803e012133bf75/pandas_timeinterval-2024.6.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f07846520afda5dfbe49264458dfe9d17a03a4fcb517c6e931821b510518194d",
"md5": "8a0ef267baef8809852db8fbc87650b0",
"sha256": "5c63cf314bcf7e2265a1e76bdb6dcc839134f0fb02fd0c11f6535bc4e12b20a3"
},
"downloads": -1,
"filename": "pandas_timeinterval-2024.6.3.tar.gz",
"has_sig": false,
"md5_digest": "8a0ef267baef8809852db8fbc87650b0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8538,
"upload_time": "2024-06-27T21:36:27",
"upload_time_iso_8601": "2024-06-27T21:36:27.767184Z",
"url": "https://files.pythonhosted.org/packages/f0/78/46520afda5dfbe49264458dfe9d17a03a4fcb517c6e931821b510518194d/pandas_timeinterval-2024.6.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-27 21:36:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jjrreett",
"github_project": "pandas-timeinterval",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pandas-timeinterval"
}