Skip to content

Instantly share code, notes, and snippets.

@lukauskas
Created March 15, 2022 12:36
Show Gist options
  • Save lukauskas/65d32167f831b0233c80aeacfc1b197d to your computer and use it in GitHub Desktop.
Save lukauskas/65d32167f831b0233c80aeacfc1b197d to your computer and use it in GitHub Desktop.
A gist illustrating the lux bug for pd.Series unique function
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "1a47ab3d-2685-4917-8512-d7ede8de5bce",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.4.0\n",
"0.5.1\n"
]
}
],
"source": [
"import pandas as pd\n",
"import lux\n",
"\n",
"print(pd.__version__)\n",
"print(lux.__version__)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a5ffbf33-43b3-4d69-bf0e-c126a5b7301a",
"metadata": {},
"outputs": [],
"source": [
"data = pd.DataFrame([['a', 1, 2], ['b', 2, 3], ['c', -1, 17]], columns=['foo', 'bar', 'baz'])"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "4e1c443a-3b4c-4f27-a77e-630cddcf39dd",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b86d19f59c0742de9313db0fc8cf8b8c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(description='Toggle Pandas/Lux', layout=Layout(top='5px', width='140px'), style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f281150947354af3ae3e75764cdbeaab",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "9a3c623d-1674-4442-9967-c150f7569dd4",
"metadata": {},
"outputs": [],
"source": [
"data = data[data['bar'] > 0]['foo']"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "5d741284-619e-4e6f-b6fd-c9eab40cfe18",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d4550ea2cb704e7caa941cd81d99d708",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(description='Toggle Pandas/Lux', layout=Layout(top='5px', width='140px'), style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a0587ab779f0448baa559f5d8d5cac2a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "fbd53c69-38a4-4d70-bd9e-bc4313d1e628",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['a', 'b', 'c'], dtype='<U1')"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.unique()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "4351905c-810b-4970-a33c-c204c7198209",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"lux.core.series.LuxSeries"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(data)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "2f484c66-646b-43ab-a5eb-c16d8369613e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['a', 'b'], dtype=object)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.Series(data).unique()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "d0a73df6-335a-4cd2-bb5d-7880be4df308",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Package Versions\n",
"----------------\n",
" Version\n",
" python 3.10.2 \n",
" lux 0.5.1 \n",
" pandas 1.4.0 \n",
" luxwidget 0.1.11 \n",
" matplotlib 3.5.1 \n",
" altair 4.2.0 \n",
" IPython 8.0.1 \n",
" ipykernel 6.9.0 \n",
" ipywidgets 7.6.5 \n",
"jupyter_client 7.1.2 \n",
" jupyter_core 4.9.1 \n",
"jupyter_server 1.13.5 \n",
" jupyterlab 3.3.0 \n",
" nbclient 0.5.10 \n",
" nbconvert 6.4.1 \n",
" nbformat 5.1.3 \n",
" notebook 6.4.8 \n",
" qtconsole 5.2.2 \n",
" traitlets 5.1.1 \n",
"\n",
"Widget Setup\n",
"-------------\n",
"✅ Jupyter Lab Running\n",
"✅ luxwidget is enabled\n",
"\n"
]
}
],
"source": [
"import lux\n",
"lux.debug_info()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f3fc146c-2700-4a0a-9289-b180da66d207",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment