Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add component api #593

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 180 additions & 0 deletions examples/component_demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "2142be9e-460c-45af-88aa-d356954b0caa",
"metadata": {},
"outputs": [],
"source": [
"import pygwalker as pyg\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7384b136-9098-482d-8914-1663547dc6ae",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(\"https://kanaries-app.s3.ap-northeast-1.amazonaws.com/public-datasets/bike_sharing_dc.csv\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "45cbe3c8-6606-498b-a741-455425798cc9",
"metadata": {},
"outputs": [],
"source": [
"pyg.component(df).bar().encode(x=\"season\", y=\"sum(casual)\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cf5f40ff-a2ed-44c6-9f85-d633b75fa020",
"metadata": {},
"outputs": [],
"source": [
"component = pyg.component(df)\n",
"component_0 = component.encode(x=\"season\", y=\"sum(casual)\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a98cf2a9-5286-4f4a-9279-d51a69d166bb",
"metadata": {},
"outputs": [],
"source": [
"component_0.bar()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d81d0c87-4c6f-42f8-8d22-8b32fc61384f",
"metadata": {},
"outputs": [],
"source": [
"component_0.area()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b5f1b05a-4b43-4f73-9558-1ce2edae81a3",
"metadata": {},
"outputs": [],
"source": [
"component_0.line()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d8f9721-688f-4ade-aaaa-577be9bda56a",
"metadata": {},
"outputs": [],
"source": [
"component_0.trail()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "901ecec4-cddc-4b74-afac-c82a7c52e98e",
"metadata": {},
"outputs": [],
"source": [
"component.scatter().encode(x=\"feeling_temp\", y=\"temperature\", color=\"humidity\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "98bb748f-0aaf-4b43-acbe-0524eafe10af",
"metadata": {},
"outputs": [],
"source": [
"component.circle().encode(x=\"feeling_temp\", y=\"temperature\", color=\"humidity\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "80c52a23-b3e3-4957-860f-21dd80b6ef47",
"metadata": {},
"outputs": [],
"source": [
"(\n",
"component\n",
" .rect()\n",
" .encode(x='bin(\"feeling_temp\", 6)', y='bin(\"temperature\", 6)', color=\"MEAN(humidity)\")\n",
" .layout(height=400, width=460)\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4cbf2edb-8bef-4190-986f-62b48517e7f4",
"metadata": {},
"outputs": [],
"source": [
"component.arc().encode(theta=\"SUM(registered)\", color=\"season\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f622848b-6122-4ee4-a7b1-d8521520b63f",
"metadata": {},
"outputs": [],
"source": [
"component_0.bar().explorer()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aafdd3b4-6819-480f-9c34-70c8d1aa410e",
"metadata": {},
"outputs": [],
"source": [
"component_0.profiling()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bff819f3-209d-4a78-b723-103b70dfb2a5",
"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.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
5 changes: 3 additions & 2 deletions pygwalker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
from pygwalker.services.global_var import GlobalVarManager
from pygwalker.services.kaggle import show_tips_user_kaggle as __show_tips_user_kaggle

__version__ = "0.4.9.1"
__version__ = "0.4.9.2"
__hash__ = __rand_str()

from pygwalker.api.jupyter import walk, render, table
from pygwalker.api.html import to_html
from pygwalker.data_parsers.base import FieldSpec
from pygwalker.api.component import component

if GlobalVarManager.privacy == 'offline':
logging.getLogger(__name__).info("Running in offline mode. There might be newer releases available. Please check at https://github.com/Kanaries/pygwalker or https://pypi.org/project/pygwalker.")

if __check_kaggle():
__show_tips_user_kaggle()

__all__ = ["walk", "render", "table", "to_html", "FieldSpec", "GlobalVarManager"]
__all__ = ["walk", "render", "table", "to_html", "FieldSpec", "GlobalVarManager", "component"]
Loading
Loading