Skip to content

Commit

Permalink
simpler import
Browse files Browse the repository at this point in the history
  • Loading branch information
raynardj committed May 1, 2022
1 parent 18e743c commit 779cc4c
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 564 deletions.
2 changes: 1 addition & 1 deletion forgebox/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.4"
__version__ = "1.0.5"
2 changes: 1 addition & 1 deletion forgebox/filter_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import List, Callable

try:
display(HTML(''''''))
display
except:
display = print

Expand Down
10 changes: 1 addition & 9 deletions forgebox/html.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 1 addition & 7 deletions forgebox/widgets.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +12,7 @@
import json

try:
display(HTML(''''''))
display
except:
display = print

Expand Down
216 changes: 56 additions & 160 deletions nbs/01_pandas_extra.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -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": {},
Expand All @@ -56,7 +45,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand All @@ -80,7 +69,7 @@
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>old</th>\n",
" <th>is_old</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
Expand All @@ -97,192 +86,99 @@
"</div>"
],
"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": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>medinc</th>\n",
" <th>houseage</th>\n",
" <th>averooms</th>\n",
" <th>avebedrms</th>\n",
" <th>population</th>\n",
" <th>aveoccup</th>\n",
" <th>latitude</th>\n",
" <th>longitude</th>\n",
" <th>old</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>8.3252</td>\n",
" <td>41.0</td>\n",
" <td>6.984127</td>\n",
" <td>1.02381</td>\n",
" <td>322.0</td>\n",
" <td>2.555556</td>\n",
" <td>37.88</td>\n",
" <td>-122.23</td>\n",
" <td>True</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"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": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>old</th>\n",
" <th>AveOccup</th>\n",
" <th>MedInc</th>\n",
" <th>HouseAge</th>\n",
" <th>AveRooms</th>\n",
" <th>AveBedrms</th>\n",
" <th>Population</th>\n",
" <th>Latitude</th>\n",
" <th>Longitude</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>True</td>\n",
" <td>2.555556</td>\n",
" <td>8.3252</td>\n",
" <td>41.0</td>\n",
" <td>6.984127</td>\n",
" <td>1.023810</td>\n",
" <td>322.0</td>\n",
" <td>37.88</td>\n",
" <td>-122.23</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>True</td>\n",
" <td>2.109842</td>\n",
" <td>8.3014</td>\n",
" <td>21.0</td>\n",
" <td>6.238137</td>\n",
" <td>0.971880</td>\n",
" <td>2401.0</td>\n",
" <td>37.86</td>\n",
" <td>-122.22</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>True</td>\n",
" <td>2.802260</td>\n",
" <td>7.2574</td>\n",
" <td>52.0</td>\n",
" <td>8.288136</td>\n",
" <td>1.073446</td>\n",
" <td>496.0</td>\n",
" <td>37.85</td>\n",
" <td>-122.24</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"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"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"df.paginate()"
]
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 779cc4c

Please sign in to comment.