Skip to main content

Utility functions for image handling

Project description

Credit to https://www.kaggle.com/code/stassl/displaying-inline-images-in-pandas-dataframe.

Usage example:

from datasets import load_dataset
# Load Fashion MNIST dataset
rows = load_dataset("zalando-datasets/fashion_mnist", split="test")
rows.set_format(type="pandas") # rows is a datasets.Dataset object from Hugging Face
df = rows[:]

from draxutils import show_pd
show_pd(df)

# if there is a column with multiple images, you can specify the column name
# show_pd(df, imglist_key='mycol')
# Timer Usage Example

from simple_timer import timer, time_this, timed
import time

# Example 1: Using the timer as a context manager
print("Example 1: Context Manager")
with timer:
    time.sleep(1)  # Simulate some work
print(timer)  # Output the elapsed time

# Example 2: Using the time_this generator
print("\nExample 2: time_this Generator")
for _ in time_this():
    time.sleep(0.5)  # Simulate some work
print(timer)  # Output the elapsed time

# Example 3: Using the timer as a decorator
print("\nExample 3: Decorator")
@timed
def some_function():
    time.sleep(0.75)  # Simulate some work

some_function()
print(f"Function execution time: {some_function.elapsed:.6f} seconds")

# Example 4: Manual usage
print("\nExample 4: Manual Usage")
timer.start_time = time.time()  # Start the timer manually
time.sleep(1.25)  # Simulate some work
timer.end_time = time.time()  # Stop the timer manually
print(f"Manual timing: {timer.elapsed:.6f} seconds")

# Example 5: Nested timers
print("\nExample 5: Nested Timers")
with timer:
    print("Outer timer started")
    time.sleep(0.5)
    with Timer() as inner_timer:
        print("Inner timer started")
        time.sleep(0.75)
    print(f"Inner timer: {inner_timer}")
print(f"Outer timer: {timer}")

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

draxutils-0.1.7.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

draxutils-0.1.7-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file draxutils-0.1.7.tar.gz.

File metadata

  • Download URL: draxutils-0.1.7.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for draxutils-0.1.7.tar.gz
Algorithm Hash digest
SHA256 1d74ce8b0f5d8963138eb91b663d68506140d97c5d8d574d3ae9e48fc6d70d6d
MD5 59aa8680197c9d7aad9bd2086ebd44b1
BLAKE2b-256 48d2cabc9e3dfc9cf8688a46c2c8c3784e22852b31f9f5936679432094b0589e

See more details on using hashes here.

File details

Details for the file draxutils-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: draxutils-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for draxutils-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 731409e029f5cf35219ef8f70c8602ecd920744e618b300249a3702a5041acff
MD5 45e88434bf91427e2dbe82cd38f5d0b3
BLAKE2b-256 93cfb24a43fa393cb9843835ef5d314e19c0ec9865383daf6767db4811e2b19e

See more details on using hashes here.

Supported by

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