Skip to main content

Deep merge, flatten, pick, omit, and transform nested dicts. Essential for data processing.

Project description

pydictutils

Deep merge, flatten, pick, omit

Installation

pip install pydictutils

💡 Usage Examples

Basic Operations

from pylib_dictutils import deep_merge, flatten_dict, pick, omit

# Deep merge dictionaries
dict1 = {"a": 1, "b": {"c": 2}}
dict2 = {"b": {"d": 3}, "e": 4}
merged = deep_merge(dict1, dict2)
# {'a': 1, 'b': {'c': 2, 'd': 3}, 'e': 4}

# Flatten nested dictionary
nested = {"a": 1, "b": {"c": 2, "d": 3}}
flat = flatten_dict(nested)
# {'a': 1, 'b.c': 2, 'b.d': 3}

# Pick specific keys
data = {"name": "John", "age": 30, "city": "NYC"}
picked = pick(data, ["name", "age"])
# {'name': 'John', 'age': 30}

# Omit specific keys
omitted = omit(data, ["age"])
# {'name': 'John', 'city': 'NYC'}

AI/ML Use Cases

from pylib_dictutils import deep_merge, flatten_dict, pick, omit

# Merge API responses with defaults
default_config = {"model": "gpt-4", "temperature": 0.7}
user_config = {"temperature": 0.9}
final_config = deep_merge(default_config, user_config)

# Flatten ML model parameters
model_params = {"layers": {"hidden": 128, "output": 10}}
flat_params = flatten_dict(model_params)
# {'layers.hidden': 128, 'layers.output': 10}

📚 API Reference

See package documentation for complete API reference.

🤖 AI Agent Friendly

This package is optimized for AI agents and code generation tools:

  • Clear function names and signatures
  • Comprehensive docstrings with examples
  • Type hints for better IDE support
  • Common use cases documented
  • Zero dependencies for reliability

License

MIT

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

pylib_dictutils-0.1.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

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

pylib_dictutils-0.1.0-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file pylib_dictutils-0.1.0.tar.gz.

File metadata

  • Download URL: pylib_dictutils-0.1.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pylib_dictutils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0f4cdb1ab3b9a802d2e150994d47f8a4ee4d076f187f70466623834c78fb3b22
MD5 f40682f1cd8e477a7b70a1ea72bc43b8
BLAKE2b-256 19b1f1dc0a546adb063c5ecba7f6eeecf500efe964383847f1768e12b3a90d3a

See more details on using hashes here.

File details

Details for the file pylib_dictutils-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pylib_dictutils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 764899dd4576dc3cffa2f948477ea1229465e9d4b3731970abd05c185ac87fa2
MD5 fa1dfe5710c180c894a428cdaaebf810
BLAKE2b-256 6e7ce0306323dac816dfb5c829af28f9a3681220de484ffba08b3f98157de3ce

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