Skip to main content

Utility functions and tools for data processing and analysis

Project description

Orama Utils

A collection of utility functions for data processing and feature engineering.

Features

  • Date feature generation: Add time-based features to your DataFrame
  • Holiday feature generation: Add holiday information based on country and region
  • Weather feature generation: (Coming soon)

Installation

You can install the package using pip:

pip install orama-utils

For development installation:

git clone https://github.com/Orama-Solutions/utils.git
cd utils
pip install -e .[dev]

Usage

Date Features

Add date-related features to your DataFrame:

import pandas as pd
from orama_utils import add_date_features

# Create your DataFrame
df = pd.DataFrame({
    'date': ['2023-01-01', '2023-12-25'],
    'value': [100, 200]
})

# Add all available date features
result = add_date_features(df, date_column='date')

# Add only specific features
selected_features = ['year', 'month', 'week_of_month', 'is_monday', 'is_weekend', 'season']
result = add_date_features(df, date_column='date', features=selected_features)

Available Date Features

  • Basic Components: year, month, day, week_of_month, week_of_year, quarter
  • Day of Week Flags: is_monday, is_tuesday, is_wednesday, is_thursday, is_friday, is_saturday, is_sunday, is_weekend
  • Calendar Flags: is_month_start, is_month_end, is_quarter_start, is_quarter_end, is_year_start, is_year_end
  • Season: season (1=Winter, 2=Spring, 3=Summer, 4=Fall for Northern Hemisphere)

Holiday Features

Add holiday-related features to your DataFrame:

import pandas as pd
from orama_utils import add_holiday_features

# Create your DataFrame
df = pd.DataFrame({
    'date': ['2023-01-01', '2023-12-25'],
    'country': ['ES', 'ES'],
    'county': ['ES-MD', 'ES-CT']
})

# Add holiday features with default threshold (3 counties)
result = add_holiday_features(df)

# With custom county threshold
result = add_holiday_features(df, county_threshold=5)

# With custom column names
result = add_holiday_features(
    df,
    date_column='date',
    country_column='country_code',
    county_column='region_code'
)

Available Holiday Features

The function adds the following columns:

  • is_public_holiday: True for national holidays
  • is_local_holiday: True for county-specific holidays
  • many_counties_holiday: True when multiple counties celebrate the holiday (more than the specified threshold)
  • is_day_before_holiday: True if the next day is a public or local holiday
  • is_day_after_holiday: True if the previous day is a public or local holiday

Supported Countries

Currently supported countries:

  • ES: Spain (with county-level holiday information)
  • IT: Italy (basic support, county-level information coming soon)

Development

Running Tests

python -m pytest tests/

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orama_utils-0.1.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orama_utils-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file orama_utils-0.1.1.tar.gz.

File metadata

  • Download URL: orama_utils-0.1.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for orama_utils-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7d3970bf60d8261ee0a862cb713913121aeecd7307723d662ae39fefe98b914d
MD5 fceef3a973d761782087e086886a4767
BLAKE2b-256 16b73009c4b9cd4ee84fae7bd3d6d53a917c4cb57ee32dc8eaf17d23551ab963

See more details on using hashes here.

File details

Details for the file orama_utils-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: orama_utils-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for orama_utils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2517fe67c12be30c21b890284573d1e40c01d08a1c888c1837e21c016d6182f6
MD5 a6db8cef69b46d37799f593cd1578506
BLAKE2b-256 2c8af0f0b2e6a97b50907b24ca27305f06c67457fffcb9aa6009de584fea04a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page