Pydash: Python Utility Library

8.0.6 · active · verified Thu Apr 09

Pydash is a Python port of the JavaScript utility library Lo-Dash, providing a comprehensive set of functional programming helpers for collections, objects, strings, and more. It aims to simplify common programming tasks with a functional, declarative style. The current version is 8.0.6, and it follows an infrequent release cadence, often aligning with major Lo-Dash updates or significant Python ecosystem changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates fetching nested data, filtering collections, and chaining multiple operations in a functional style, which is a core feature of pydash. It uses common functions like `get`, `filter_`, `map_`, and `chain`.

import pydash

data = {
    'user': 'fred',
    'age': 40,
    'active': False,
    'posts': [
        {'title': 'Post 1', 'tags': ['news', 'tech']},
        {'title': 'Post 2', 'tags': ['coding', 'python']}
    ]
}

# Get a deeply nested value
post_tag = pydash.get(data, 'posts[0].tags[1]')
print(f"Deeply nested tag: {post_tag}")

# Filter a list of dictionaries
python_posts = pydash.filter_(data['posts'], lambda x: 'python' in x['tags'])
print(f"Posts about Python: {python_posts}")

# Chain operations for a more functional style
chained_result = pydash.chain(data['posts']) \
    .filter_(lambda x: 'python' in x['tags']) \
    .map_('title') \
    .value()
print(f"Chained operation result: {chained_result}")

view raw JSON →