NQDM -- An extension of TQDM which enables you to loop over multiple objects simultaneously, and specify the depth of iteration for each object. It is just pure Python magic, no extra libraries needed. It is customizable, minimal and open source.
Project description
NQDM
A more generalised implementation to TQDM-progress bars, which simulates a single loop for multiple loops and returns multiple indices at the same time. It is compatible with many data types, is customizable and beginner-friendly.
Installing
Install it using the terminal
git clone https://github.com/yamaceay/nqdm.git
or install it on a .ipynb notebook.
!git clone https://github.com/yamaceay/nqdm.git
Getting Started
First of all, you need to import nqdm.
from nqdm import nqdm
Let's explore some use cases of nqdm:
Working With Different Data Types
There are three types of arguments:
- length: returns
0, ..., length-1
- array: returns
array[0], ..., array[length-1]
- hashable: returns
{keys[0]: values[0]}, ..., {keys[length-1]: values[length-1]}
A more detailled list of available arguments and return values:
Argument | Type of Argument | Returns |
---|---|---|
length | int | range(length) |
length | float | range(int(length)) |
array | numpy.ndarray | list(array) |
array | range | list(array) |
array | list | array |
array | str | list(array) |
hashable | pandas.core.series.Series | [{k: v} for k, v in zip(hashable.index, hashable.values)] |
hashable | dict | [{k: v} for k, v in hashable.items()] |
Length variables (int, float)
Input:
len_1 = 2.0
len_2 = 3
for i in nqdm(len_1, len_2):
print(i)
Output:
Lists and NumPy arrays
Input:
arg_1 = [1, 2, 3]
arg_2 = np.array([4, 5, 6])
for i in nqdm(arg_1, arg_2):
print(i)
Output:
Strings
Input:
arg_1 = list("abc")
arg_2 = "cde"
for i in nqdm(arg_1, arg_2):
print(i)
Output:
Dictionaries and Pandas Series
Input:
arg_1 = {"key1": 4, "key2": 5}
arg_2 = pd.Series(["horse", "cat", "mouse"], index=[978, 979, 980])
for i in nqdm(arg_1, arg_2):
print(i)
Output:
NEW: Usage of Depth Feature
Input:
list_of_list_of_lists = [[[0, 1], [2, 3]], [[4, 5], [6, 7]]]
for list_of_list in nqdm(list_of_list_of_lists, depth=0):
print(list_of_list)
Output:
Input:
list_of_list_of_lists = np.arange(8).reshape(2, 2, 2)
for arr in nqdm(list_of_list_of_lists, depth=1):
print(arr)
Output:
Input:
list_of_dict_of_lists = [{"a": [0, 1], "b": [2, 3]}, {"a": [4, 5], "b": [6, 7]}]
for elem in nqdm(list_of_dict_of_lists, depth=2):
print(elem)
Output:
Input:
list_of_list_of_lists = np.arange(8).reshape(2, 2, 2)
list_of_list_of_dicts = [[{"a": 1, "b": 2}, {"c": 3, "d": 4}], [{"e": 5, "f": 6}, {"g": 7, "h": 8}]]
for elems in nqdm(list_of_list_of_lists, list_of_list_of_dicts, depth=[0, 1]):
print(elems)
Output:
NEW: Usage of Order Feature
Input:
for i in nqdm(2, 2, 2, order = "last"):
print(i)
Output:
Input:
for i in nqdm(2, 2, 2, order = "first"):
print(i)
Output:
Input:
for i in nqdm(2, 2, 2, order = [1, 2, 0]):
print(i)
Output:
Built With
Authors
- Yamac Eren Ay - Initial work - yamaceay
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Special Thanks to:
Acknowledgments
It's worth mentioning that this module is built on top of TQDM, I would like to thank them for doing the real hard job and making this process of creating progress bars easy and flexible.
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.