Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
About Article
Analyze Data
Archive
Best Practices
Better Outputs
Blog
Code Optimization
Code Quality
Command Line
Course
Daily tips
Dashboard
Data Analysis & Manipulation
Data Engineer
Data Visualization
DataFrame
Delta Lake
DevOps
DuckDB
Environment Management
Feature Engineer
Git
Jupyter Notebook
LLM
LLM Tools
Machine Learning
Machine Learning & AI
Machine Learning Tools
Manage Data
MLOps
Natural Language Processing
Newsletter Archive
NumPy
Pandas
Polars
PySpark
Python Helpers
Python Tips
Python Utilities
Scrape Data
SQL
Testing
Time Series
Tools
Visualization
Visualization & Reporting
Workflow & Automation
Workflow Automation

Python Utilities

Pydash’s Method Chaining

Lazy evaluation is an evaluation strategy that holds the evaluation of an expression until its value is needed. This method avoids repeated evaluation and discards sub-expressions that are not directly linked to the final result of the expression.

To use lazy evaluation in Python, use pydash’s method chaining. pydash’s method chaining also increases the readability of your code when applying multiple methods to a Python object.

Link to pydash.

Play with pydash in this Google Colab notebook.

Pydash’s Method Chaining Read More »

attrs: Bring Back the Joy of Writing Classes

Do you find it annoying to write an __init__ method every time you want to create a class in Python? If so, try attrs.

attrs allows you to:

declaratively define the attributes of a classget a nice human-readable __repr__ without extra codeturn attributes of an instance into a dictionary

Find other benefits of using attrs here.

Link to my previous tips on Python classes.

attrs: Bring Back the Joy of Writing Classes Read More »

itertools.starmap: Apply a Function With More Than 2 Arguments to Elements in a List

map is a useful method that allows you to apply a function to elements in a list. However, it can’t apply a function with more than one argument to a list.
To apply a function with more than 2 arguments to elements in a list, use itertools.starmap. With starmap, elements in each tuple of the list nums are used as arguments for the function multiply.
Link to my previous tips about itertools.

itertools.starmap: Apply a Function With More Than 2 Arguments to Elements in a List Read More »

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran