{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "flex_title = \"NBA Scoring (2008)\"\n", "flex_orientation = \"rows\"\n", "flex_source_code = \"https://github.com/danielfrg/jupyter-flex/blob/master/examples/nba-scoring.ipynb\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "import plotly.graph_objects as go" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "url = \"http://datasets.flowingdata.com/ppg2008.csv\"\n", "df = pd.read_csv(url)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = df.rename(columns={\"Name \": \"Name\"})" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = df.set_index(\"Name\")" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "size=650" ] }, "source": [ "### Heatmap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "source = (df-df.mean())/df.std()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "chart" ] }, "outputs": [], "source": [ "heatmap = go.Heatmap(x=source.columns, y=source.index, z=source, hoverongaps=False, colorscale='Viridis', showscale=False)\n", "\n", "fig = go.FigureWidget(data=heatmap)\n", "\n", "margin = go.layout.Margin(l=20, r=20, b=20, t=30)\n", "fig.update_layout(margin=margin)\n", "\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "footer" ] }, "source": [ "Normalized stats by players" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "size=350" ] }, "source": [ "### Table" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "chart" ] }, "outputs": [], "source": [ "df.index.name = \"\"\n", "df[[\"G\", \"MIN\", \"PTS\"]].iloc[:20]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "celltoolbar": "Tags", "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.8.0" } }, "nbformat": 4, "nbformat_minor": 4 }