Skip to main content

Data science with fancy loops

Project description

ForgeBox

Data science comprehensive toolbox 🛠⚔️📦

logo

Installation

Easy simple installation in 1 shot

pip install forgebox

If not specified, you need anaconda3 for most of the tools, python shold be at least >=3.6

Features 🚀 Briefing

This is a tool box with comprehensive utilies, to put it simply, I just hope most of my frequetyly used DIY tools in in place and can be easily installed and imported

Lazy, fast imports 🤯

The following command will import many frequent tools for data science, like pd for pandas, np for numpy, os, json, PIL.Image for image processing

from frogebox.imports import *

No more🚫 following typings

import pandas as pd
import numpy as np
import os
import json
...

Free style mapping

Works on every value of a complicated dictionary structure (eg. list in dict in list in dict, etc,. 😳)

from forgebox.freemap import FreeMap

# flatten decides if we want to flatten the strucuture
freemap_tool = FreeMap(
    <function/callable applying to every value>,
    <function/callable that filters every value>,
    flatten=True
)

data2 = freemap_tool(data1)

Interactive Widgets

Interactive widgets work with in jupyter notebooks

Search box 🔎 for dataframe

This will create an interactive text input box to search through the pandas dataframe, within the columns you set.

if manual is set to False, the search will respond to each of your key press, it's fast but will suffer terrible user experience if the dataframe is huge in size.

from forgebox.widgets import search_box

search_box(data_df, columns=["col1","col2"], manual=False)

paginate

You can browse through a pandas dataframe like fliping pages 📄.

from forgebox.widgets import paginate

paginate(your_dataframe, page_len=10)

Single button callback

a fully functional page with a single button, this single button is bonded to a function

This is as much code as you need, to build a fully functional interactive page shows sql table from jupyter, that you can:✅ choose which table to visit✅ choose how many lines you want to show, (with a slider)✅ configure the where condition with a text box on front end

tablename_list = ["pubmed", "patient", "users", "drugs"]

from forgebox.html import DOM
def show_sql_table(sql_input:str) -> str:
    with engine.connect() as conn:
        df=pd.read_sql(sql_input, con=conn)
    # display the table as html
    DOM(df.to_html(),"div")()

@SingleButton(callback=show_sql_table)
def abc(
    limit:{"typing":int, "default":10, "min":5, "max":20},
    where_condition:{"typing":str, "default": "where 1=1", },
    table:{"typing":list, "options":tablename_list}
):
    return f"sql > SELECT * FROM {table} {where_condition} LIMIT {limit}"

Dataset Layering 🍰

Instead of creating a bunch of dataset just treat another dataset as extra layer of getitem function

@layering(SomeStringDataset, "tensorDataset")
def tokenizing(x):
    return tokenizer(x, return_tensors='pt')['input_ids'][0]

@layering(tokenizing, "guessNextDataset")
def guess_next(x):
    return x[:-1], x[1:]

some_string_data = SomeStringDataset()

tokenized_data = some_string_data.next_layer()
print(tokenized_data[3])

guess_pair = tokenized_data.next_layer()
print(guess_pair[3])

And you can test these layer functions one by one

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

forgebox-0.3.14.tar.gz (56.1 kB view details)

Uploaded Source

Built Distribution

forgebox-0.3.14-py3-none-any.whl (75.3 kB view details)

Uploaded Python 3

File details

Details for the file forgebox-0.3.14.tar.gz.

File metadata

  • Download URL: forgebox-0.3.14.tar.gz
  • Upload date:
  • Size: 56.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.4

File hashes

Hashes for forgebox-0.3.14.tar.gz
Algorithm Hash digest
SHA256 72d7ff8b29d688e066145376565cbee04687cdbc3688d2493dbb3450269a9061
MD5 a00ea05fe1f8ce8dadfdf2b8a8adaa97
BLAKE2b-256 c2d91e64251142fd2153952b4c74185aa70c2d26e3b28185c0f4a0e356505448

See more details on using hashes here.

File details

Details for the file forgebox-0.3.14-py3-none-any.whl.

File metadata

  • Download URL: forgebox-0.3.14-py3-none-any.whl
  • Upload date:
  • Size: 75.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.4

File hashes

Hashes for forgebox-0.3.14-py3-none-any.whl
Algorithm Hash digest
SHA256 752bedc7176614812f1b98f95f93a1e99f778f04ab60628350ba9f1a4bdaa5f6
MD5 3d4841f119662ec5657e5dfc2253f132
BLAKE2b-256 5c66dbdedd9aa2571d26dac35d3d6edfbc3751bed6dfff3d9f6a6f057d012b6d

See more details on using hashes here.

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