HydUtils is a Python utility library designed for data handling and validation, especially for time series and hydrological datasets.
Project description
HydUtils
HydUtils is a Python utility library designed for data handling and validation, especially for time series and hydrological datasets. It provides several useful functions for working with time series data, including validation, filtering, and checking for missing values.
This library helps ensure data integrity and consistency, making it easier to work with time-based datasets.
Installation
pip install hydutils
Usage
1. Validate Columns for Nulls
The function validate_columns_for_nulls checks for columns that contain null values and raises an error if any are found.
from hydutils.df_validation import validate_columns_for_nulls
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, None], "c": [7, 8, 9]})
# Validate for null values in any column
validate_columns_for_nulls(df)
# Specify columns to check
validate_columns_for_nulls(df, columns=["b"])
# Handling missing columns
validate_columns_for_nulls(df, columns=["d"]) # This will raise an error if column "d" is missing
2. Validate Time Series Interval
The validate_interval function checks that the time intervals between rows in the time series are consistent.
from hydutils.df_validation import validate_interval
import pandas as pd
df = pd.DataFrame({
"time": pd.date_range(start="2023-01-01", periods=5, freq="h")
})
# Check if the time intervals are consistent
validate_interval(df, interval=1)
3. Filter Time Series
The filter_timeseries function allows you to filter your time series DataFrame based on a start and/or end date.
from hydutils.df_validation import filter_timeseries
import pandas as pd
from datetime import datetime
df = pd.DataFrame({
"time": pd.date_range(start="2023-01-01", periods=5, freq="h")
})
# Filter data between a start and end date
start = datetime(2023, 1, 1, 1)
end = datetime(2023, 1, 1, 3)
filtered_data = filter_timeseries(df, start=start, end=end)
License
This library is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hydutils-1.0.0.tar.gz.
File metadata
- Download URL: hydutils-1.0.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-49-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59eb0d1d421e6d27e1d88ef9621855ad102ffbfe8911ff8485fc88e9f003f639
|
|
| MD5 |
7ae2cd648665a7b6c4d269e69cc17059
|
|
| BLAKE2b-256 |
c287b54bc78cc29e55d3f0c68ee59794ae946b52b204461285689595717860be
|
File details
Details for the file hydutils-1.0.0-py3-none-any.whl.
File metadata
- Download URL: hydutils-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-49-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7efc24c81b10be48243bec60e52449339cc6db72779d347493f692415ab22d6
|
|
| MD5 |
2a9a115a89c720413a90dcfc0a201d1e
|
|
| BLAKE2b-256 |
358b444fd076ab18e1071df054c1ef10c8674a16d446bd5f9b0853f5413274ec
|