diff --git a/forgebox/__init__.py b/forgebox/__init__.py
index 92192ee..68cdeee 100644
--- a/forgebox/__init__.py
+++ b/forgebox/__init__.py
@@ -1 +1 @@
-__version__ = "1.0.4"
+__version__ = "1.0.5"
diff --git a/forgebox/filter_df.py b/forgebox/filter_df.py
index 8d33226..7c1c060 100644
--- a/forgebox/filter_df.py
+++ b/forgebox/filter_df.py
@@ -9,7 +9,7 @@
from typing import List, Callable
try:
- display(HTML(''''''))
+ display
except:
display = print
diff --git a/forgebox/html.py b/forgebox/html.py
index 762ba8a..30b43a8 100644
--- a/forgebox/html.py
+++ b/forgebox/html.py
@@ -1,20 +1,12 @@
-# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/04_html.ipynb (unless otherwise specified).
-
import math
from PIL.Image import Image as ImageClass
import base64
from io import BytesIO
-__all__ = ['display', 'DOM', 'image_to_base64', 'data_url',
- 'img_dom', 'deeper', 'list_group',
- 'col_sm', 'list_group_kv', 'JS',
- 'JS_file']
-
-# Cell
from IPython.display import HTML
from typing import Dict, Any
try:
- display(HTML(''''''))
+ display
except:
display = print
diff --git a/forgebox/widgets.py b/forgebox/widgets.py
index ae03065..46a53d8 100644
--- a/forgebox/widgets.py
+++ b/forgebox/widgets.py
@@ -1,9 +1,3 @@
-# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/05_inter_widgets.ipynb (unless otherwise specified).
-
-__all__ = ['display_df', 'search_box', 'paginate', 'make_hboxes', 'SingleButton', 'Labeler', 'EditableList',
- 'EditableDict', 'total_width', 'LivingStep', 'StepByStep']
-
-# Cell
import pandas as pd
from .df import PandasDisplay
from .html import list_group, list_group_kv
@@ -18,7 +12,7 @@
import json
try:
- display(HTML(''''''))
+ display
except:
display = print
diff --git a/nbs/01_pandas_extra.ipynb b/nbs/01_pandas_extra.ipynb
index 168c6c3..93d03f4 100644
--- a/nbs/01_pandas_extra.ipynb
+++ b/nbs/01_pandas_extra.ipynb
@@ -10,7 +10,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -32,21 +32,10 @@
"outputs": [],
"source": [
"from sklearn.datasets import california_housing\n",
- "\n",
"cdata = california_housing.fetch_california_housing()\n",
- "\n",
"df = pd.DataFrame(cdata[\"data\"], columns=cdata[\"feature_names\"])"
]
},
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [],
- "source": [
- "df[\"old\"] = df.HouseAge>20"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -56,7 +45,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
@@ -80,7 +69,7 @@
" \n",
" \n",
" | \n",
- " old | \n",
+ " is_old | \n",
"
\n",
" \n",
"
\n",
@@ -97,184 +86,89 @@
""
],
"text/plain": [
- " old\n",
- "True 14347\n",
- "False 6293"
+ " is_old\n",
+ "True 14347\n",
+ "False 6293"
]
},
- "execution_count": 4,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "df.vc(\"old\")"
+ "df[\"is_old\"] = df.HouseAge>20\n",
+ "df.vc(\"is_old\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Rename columns"
]
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " medinc | \n",
- " houseage | \n",
- " averooms | \n",
- " avebedrms | \n",
- " population | \n",
- " aveoccup | \n",
- " latitude | \n",
- " longitude | \n",
- " old | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 0 | \n",
- " 8.3252 | \n",
- " 41.0 | \n",
- " 6.984127 | \n",
- " 1.02381 | \n",
- " 322.0 | \n",
- " 2.555556 | \n",
- " 37.88 | \n",
- " -122.23 | \n",
- " True | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
- ],
"text/plain": [
- " medinc houseage averooms avebedrms ... aveoccup latitude longitude old\n",
- "0 8.3252 41.0 6.984127 1.02381 ... 2.555556 37.88 -122.23 True\n",
- "\n",
- "[1 rows x 9 columns]"
+ "Index(['MedInc', 'HouseAge', 'AveRooms', 'AveBedrms', 'Population', 'AveOccup',\n",
+ " 'Latitude', 'Longitude', 'old'],\n",
+ " dtype='object')"
]
},
- "execution_count": 8,
+ "execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "df.rename_by_rule().head(1)"
+ "df.columns"
]
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 6,
"metadata": {},
"outputs": [
{
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " old | \n",
- " AveOccup | \n",
- " MedInc | \n",
- " HouseAge | \n",
- " AveRooms | \n",
- " AveBedrms | \n",
- " Population | \n",
- " Latitude | \n",
- " Longitude | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 0 | \n",
- " True | \n",
- " 2.555556 | \n",
- " 8.3252 | \n",
- " 41.0 | \n",
- " 6.984127 | \n",
- " 1.023810 | \n",
- " 322.0 | \n",
- " 37.88 | \n",
- " -122.23 | \n",
- "
\n",
- " \n",
- " 1 | \n",
- " True | \n",
- " 2.109842 | \n",
- " 8.3014 | \n",
- " 21.0 | \n",
- " 6.238137 | \n",
- " 0.971880 | \n",
- " 2401.0 | \n",
- " 37.86 | \n",
- " -122.22 | \n",
- "
\n",
- " \n",
- " 2 | \n",
- " True | \n",
- " 2.802260 | \n",
- " 7.2574 | \n",
- " 52.0 | \n",
- " 8.288136 | \n",
- " 1.073446 | \n",
- " 496.0 | \n",
- " 37.85 | \n",
- " -122.24 | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
- ],
- "text/plain": [
- " old AveOccup MedInc HouseAge ... AveBedrms Population Latitude Longitude\n",
- "0 True 2.555556 8.3252 41.0 ... 1.023810 322.0 37.88 -122.23\n",
- "1 True 2.109842 8.3014 21.0 ... 0.971880 2401.0 37.86 -122.22\n",
- "2 True 2.802260 7.2574 52.0 ... 1.073446 496.0 37.85 -122.24\n",
- "\n",
- "[3 rows x 9 columns]"
- ]
- },
- "execution_count": 7,
- "metadata": {},
- "output_type": "execute_result"
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['medinc', 'houseage', 'averooms', 'avebedrms', 'population', 'aveoccup', 'latitude', 'longitude']\n"
+ ]
}
],
"source": [
- "df.column_order(\"old\",\"AveOccup\").head(3)"
+ "print(list(df.rename_by_rule().columns))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['is_old', 'AveOccup', 'MedInc', 'HouseAge', 'AveRooms', 'AveBedrms', 'Population', 'Latitude', 'Longitude']\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(list(df.column_order(\"is_old\",\"AveOccup\").columns))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Paginate"
]
},
{
@@ -282,7 +176,9 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "df.paginate()"
+ ]
}
],
"metadata": {
diff --git a/nbs/06_flatten.ipynb b/nbs/06_flatten.ipynb
deleted file mode 100644
index 04bf542..0000000
--- a/nbs/06_flatten.ipynb
+++ /dev/null
@@ -1,142 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Flatten"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [],
- "source": [
- "# default_exp flatten"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Flattening the tree structure"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [],
- "source": [
- "# export\n",
- "\n",
- "from typing import List, Callable, Any, Dict\n",
- "class Flatten:\n",
- " \"\"\"\n",
- " Flatten a tree structure dictionary\n",
- " \"\"\"\n",
- " def __init__(\n",
- " self, data,\n",
- " key_callback: Callable = None,\n",
- " key_connection: str = \"_\",\n",
- " ):\n",
- " self.data = data\n",
- " self.key_callback = key_callback\n",
- " self.key_connection = key_connection\n",
- "\n",
- " def flattening(\n",
- " self, data,\n",
- " result=None,\n",
- " upper_key=\"\"\n",
- " ) -> Dict[str, str]:\n",
- " \"\"\"\n",
- " Recursive flatten function\n",
- " \"\"\"\n",
- " if result is None:\n",
- " result = {}\n",
- " for key, value in data.items():\n",
- " if self.key_callback is not None:\n",
- " key = self.key_callback(key)\n",
- " if isinstance(value, dict):\n",
- " self.flattening(value, result,\n",
- " upper_key=f\"{key}{self.key_connection}\")\n",
- " else:\n",
- " result[f\"{upper_key}{key}\"] = value\n",
- " return result\n",
- "\n",
- " def __call__(self) -> Dict[str, str]:\n",
- " return self.flattening(self.data)\n",
- " \n"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Testing a tree structure"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "{'a': [1, 2, {'c': 'd'}], 'b=>g': 1}"
- ]
- },
- "execution_count": 10,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "Flatten({\"a\":[1,2,{\"c\":\"d\"}],\"b\":{\"g\":1}}, key_connection=\"=>\")()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.7.4"
- },
- "toc": {
- "base_numbering": 1,
- "nav_menu": {},
- "number_sections": true,
- "sideBar": true,
- "skip_h1_title": false,
- "title_cell": "Table of Contents",
- "title_sidebar": "Contents",
- "toc_cell": false,
- "toc_position": {},
- "toc_section_display": true,
- "toc_window_display": false
- }
- },
- "nbformat": 4,
- "nbformat_minor": 4
-}
diff --git a/nbs/31_df_filter.ipynb b/nbs/31_df_filter.ipynb
index edd5e7c..599d13b 100644
--- a/nbs/31_df_filter.ipynb
+++ b/nbs/31_df_filter.ipynb
@@ -10,7 +10,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 2,
"metadata": {},
"outputs": [
{
@@ -26,7 +26,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "9b80848c8fa145a8b1e0280678df5b6f",
+ "model_id": "6c12e150b8404043a90b4afcb9c92084",
"version_major": 2,
"version_minor": 0
},
@@ -44,7 +44,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 3,
"metadata": {
"code_folding": []
},
@@ -59,167 +59,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/salvor/anaconda3/lib/python3.7/site-packages/sklearn/feature_extraction/image.py:167: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
- "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
- " dtype=np.int):\n"
- ]
- }
- ],
- "source": [
- "df = get_cal_housing()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " MedInc | \n",
- " HouseAge | \n",
- " AveRooms | \n",
- " AveBedrms | \n",
- " Population | \n",
- " AveOccup | \n",
- " Latitude | \n",
- " Longitude | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 0 | \n",
- " 8.3252 | \n",
- " 41.0 | \n",
- " 6.984127 | \n",
- " 1.023810 | \n",
- " 322.0 | \n",
- " 2.555556 | \n",
- " 37.88 | \n",
- " -122.23 | \n",
- "
\n",
- " \n",
- " 1 | \n",
- " 8.3014 | \n",
- " 21.0 | \n",
- " 6.238137 | \n",
- " 0.971880 | \n",
- " 2401.0 | \n",
- " 2.109842 | \n",
- " 37.86 | \n",
- " -122.22 | \n",
- "
\n",
- " \n",
- " 2 | \n",
- " 7.2574 | \n",
- " 52.0 | \n",
- " 8.288136 | \n",
- " 1.073446 | \n",
- " 496.0 | \n",
- " 2.802260 | \n",
- " 37.85 | \n",
- " -122.24 | \n",
- "
\n",
- " \n",
- " 3 | \n",
- " 5.6431 | \n",
- " 52.0 | \n",
- " 5.817352 | \n",
- " 1.073059 | \n",
- " 558.0 | \n",
- " 2.547945 | \n",
- " 37.85 | \n",
- " -122.25 | \n",
- "
\n",
- " \n",
- " 4 | \n",
- " 3.8462 | \n",
- " 52.0 | \n",
- " 6.281853 | \n",
- " 1.081081 | \n",
- " 565.0 | \n",
- " 2.181467 | \n",
- " 37.85 | \n",
- " -122.25 | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
- ],
- "text/plain": [
- " MedInc HouseAge AveRooms AveBedrms Population AveOccup Latitude \\\n",
- "0 8.3252 41.0 6.984127 1.023810 322.0 2.555556 37.88 \n",
- "1 8.3014 21.0 6.238137 0.971880 2401.0 2.109842 37.86 \n",
- "2 7.2574 52.0 8.288136 1.073446 496.0 2.802260 37.85 \n",
- "3 5.6431 52.0 5.817352 1.073059 558.0 2.547945 37.85 \n",
- "4 3.8462 52.0 6.281853 1.081081 565.0 2.181467 37.85 \n",
- "\n",
- " Longitude \n",
- "0 -122.23 \n",
- "1 -122.22 \n",
- "2 -122.24 \n",
- "3 -122.25 \n",
- "4 -122.25 "
- ]
- },
- "execution_count": 4,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "df.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "(False, True)"
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "\"32.8%\">\"35.2%\", \"32.8%\">\"15.2%\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
+ "execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -265,17 +105,6 @@
" 37.88 | \n",
" -122.23 | \n",
" \n",
- " \n",
- " 1 | \n",
- " 8.3014 | \n",
- " 21.0 | \n",
- " 6.238137 | \n",
- " 0.97188 | \n",
- " 2401.0 | \n",
- " 2.109842 | \n",
- " 37.86 | \n",
- " -122.22 | \n",
- "
\n",
" \n",
"\n",
""
@@ -283,20 +112,19 @@
"text/plain": [
" MedInc HouseAge AveRooms AveBedrms Population AveOccup Latitude \\\n",
"0 8.3252 41.0 6.984127 1.02381 322.0 2.555556 37.88 \n",
- "1 8.3014 21.0 6.238137 0.97188 2401.0 2.109842 37.86 \n",
"\n",
" Longitude \n",
- "0 -122.23 \n",
- "1 -122.22 "
+ "0 -122.23 "
]
},
- "execution_count": 6,
+ "execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "df.head(2)"
+ "df = get_cal_housing()\n",
+ "df.head(1)"
]
},
{
@@ -360,71 +188,11 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " MedInc | \n",
- " HouseAge | \n",
- " AveRooms | \n",
- " AveBedrms | \n",
- " Population | \n",
- " AveOccup | \n",
- " Latitude | \n",
- " Longitude | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 0 | \n",
- " 8.3252 | \n",
- " 41.0 | \n",
- " 6.984127 | \n",
- " 1.02381 | \n",
- " 322.0 | \n",
- " 2.555556 | \n",
- " 37.88 | \n",
- " -122.23 | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
- ],
- "text/plain": [
- " MedInc HouseAge AveRooms AveBedrms Population AveOccup Latitude \\\n",
- "0 8.3252 41.0 6.984127 1.02381 322.0 2.555556 37.88 \n",
- "\n",
- " Longitude \n",
- "0 -122.23 "
- ]
- },
- "execution_count": 11,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
- "data_filter.df.head(1)"
+ "data_filter.df"
]
},
{
diff --git a/settings.ini b/settings.ini
index b49c171..1b7dd74 100644
--- a/settings.ini
+++ b/settings.ini
@@ -7,7 +7,7 @@ author = xiaochen(ray) zhang
author_email = b2ray2c@gmail.com
copyright = xiaochen(ray) zhang
branch = master
-version = 1.0.4
+version = 1.0.5
min_python = 3.6
host = github
audience = Developers