DEV Community

Guru prasanna
Guru prasanna

Posted on

Task-Python Packages

Few Python Packages

Progress Bar and TQDM:
To implement progress bars for tasks such as loops, file processing, or downloads.

from progress.bar import ChargingBar
bar = ChargingBar('Processing', max=20)
for i in range(20):
    # Do some work
    bar.next()
bar.finish()
Enter fullscreen mode Exit fullscreen mode

Output:

Processing ████████████████████████████████ 100%
Enter fullscreen mode Exit fullscreen mode

TQDM: Similar to progress bar but its more simple to setup than progress bar.

from tqdm import tqdm
import time

for i in tqdm(range(100)):
    time.sleep(0.1)
Enter fullscreen mode Exit fullscreen mode

Output:

100%|██████████████████████████████████████| 100/100 [00:00<00:00, 18784.11it/s]
Enter fullscreen mode Exit fullscreen mode

Matplotlib:

Matplotlib is used for creating static, animated, and interactive visualizations.

import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

plt.plot(x, y, label='Linear Growth', color='blue', linestyle='--', marker='o')
plt.title("Line Plot Example")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.legend()
plt.show()
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Numpy:
NumPy (Numerical Python) is a fundamental Python library for numerical computing. It provides support for working with large, multi-dimensional arrays (like 1-D,2-D,3-D) and matrices, along with a collection of mathematical functions to operate on these arrays efficiently.

Example:

import numpy as np

# 1D array
arr1 = np.array([1, 2, 3, 4])

# 2D array
arr2 = np.array([[1, 2], [3, 4]])

print(arr1, arr2)
Enter fullscreen mode Exit fullscreen mode

Output:

[1 2 3 4] [[1 2]
 [3 4]]

Enter fullscreen mode Exit fullscreen mode

Pandas:
It is used for data manipulation and analysis with Series(lists) and DataFrame(table or spreadsheet).

Example:

import pandas
x=[1,2,3]
y=pandas.Series(x,index=["no1","no2","no3"])
print(y)
Enter fullscreen mode Exit fullscreen mode

Output:

no1    1
no2    2
no3    3
dtype: int64
Enter fullscreen mode Exit fullscreen mode

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more