Skip to main content

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

logo1

A Gentle Introduction

A more generalised implementation to TQDM-progress bars, which simulates a single loop for multiple loops and returns multiple elements at the same time. It can iterate over the deeper levels. It is compatible with many data types, is customizable and beginner-friendly.

Installing

Install it using the terminal

pip install nqdm

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:

  1. constant: returns 0, ..., constant-1
  2. iterable: returns iterable[0], ..., iterable[-1]
  3. hashable: returns {keys[0]: values[0]}, ..., {keys[-1]: values[-1]}

A more detailled list of available arguments and return values:

Argument Type of Argument Returns
constant int, float, double range(int(constant))
iterable numpy.ndarray, range, list, 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:

NQDM_01

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:

NQDM_02

Strings

Input:

arg_1 = list("abc")
arg_2 = "cde"

for i in nqdm(arg_1, arg_2):
  print(i)

Output:

NQDM_03

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:

NQDM_04

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:

NQDM_05

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:

NQDM_06

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:

NQDM_07

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:

NQDM_08

NEW: Usage of Order Feature

Input:

for i in nqdm(2, 2, 2, order = "last"):
    print(i)

Output:

NQDM_9)

Input:

for i in nqdm(2, 2, 2, order = "first"):
    print(i)

Output:

NQDM_10

Input:

for i in nqdm(2, 2, 2, order = [1, 2, 0]):
    print(i)

Output:

NQDM_11

NEW: Usage of Enum Feature

Input:

data = pd.DataFrame({"x1": [2, 3, 5], "x2": [9, 8, 2], "x3": [0, 0, 2]})

for i in nqdm(data, enum=True, depth=1):
    print(i)

Output:

NQDM_12

Built With

  • tqdm - The progress bar

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 making this process of creating progress bars easy and flexible.

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

nqdm-0.1.6.tar.gz (8.9 kB view hashes)

Uploaded Source

Built Distribution

nqdm-0.1.6-py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 3

Supported by

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