diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 21104c2e00450..d0afdb4df596f 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -100,7 +100,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.sparse.fill_value SA01" \ -i "pandas.Series.sparse.from_coo PR07,SA01" \ -i "pandas.Series.sparse.npoints SA01" \ - -i "pandas.Series.sparse.sp_values SA01" \ -i "pandas.Timedelta.max PR02" \ -i "pandas.Timedelta.min PR02" \ -i "pandas.Timedelta.resolution PR02" \ diff --git a/doc/source/user_guide/style.ipynb b/doc/source/user_guide/style.ipynb index daecfce6ecebc..1afc5d0cf3b3c 100644 --- a/doc/source/user_guide/style.ipynb +++ b/doc/source/user_guide/style.ipynb @@ -46,7 +46,6 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot\n", "# We have this here to trigger matplotlib's font cache stuff.\n", "# This cell is hidden from the output" ] @@ -78,7 +77,6 @@ "source": [ "import pandas as pd\n", "import numpy as np\n", - "import matplotlib as mpl\n", "\n", "df = pd.DataFrame({\n", " \"strings\": [\"Adam\", \"Mike\"],\n", @@ -104,11 +102,11 @@ "metadata": {}, "outputs": [], "source": [ - "weather_df = pd.DataFrame(np.random.rand(10,2)*5, \n", + "weather_df = pd.DataFrame(np.random.rand(10,2)*5,\n", " index=pd.date_range(start=\"2021-01-01\", periods=10),\n", " columns=[\"Tokyo\", \"Beijing\"])\n", "\n", - "def rain_condition(v): \n", + "def rain_condition(v):\n", " if v < 1.75:\n", " return \"Dry\"\n", " elif v < 2.75:\n", @@ -227,9 +225,9 @@ "metadata": {}, "outputs": [], "source": [ - "df = pd.DataFrame([[38.0, 2.0, 18.0, 22.0, 21, np.nan],[19, 439, 6, 452, 226,232]], \n", - " index=pd.Index(['Tumour (Positive)', 'Non-Tumour (Negative)'], name='Actual Label:'), \n", - " columns=pd.MultiIndex.from_product([['Decision Tree', 'Regression', 'Random'],['Tumour', 'Non-Tumour']], names=['Model:', 'Predicted:']))\n", + "df = pd.DataFrame([[38.0, 2.0, 18.0, 22.0, 21, np.nan],[19, 439, 6, 452, 226,232]],\n", + " index=pd.Index([\"Tumour (Positive)\", \"Non-Tumour (Negative)\"], name=\"Actual Label:\"),\n", + " columns=pd.MultiIndex.from_product([[\"Decision Tree\", \"Regression\", \"Random\"],[\"Tumour\", \"Non-Tumour\"]], names=[\"Model:\", \"Predicted:\"]))\n", "df.style" ] }, @@ -243,62 +241,62 @@ "source": [ "# Hidden cell to just create the below example: code is covered throughout the guide.\n", "s = df.style\\\n", - " .hide([('Random', 'Tumour'), ('Random', 'Non-Tumour')], axis='columns')\\\n", - " .format('{:.0f}')\\\n", + " .hide([(\"Random\", \"Tumour\"), (\"Random\", \"Non-Tumour\")], axis=\"columns\")\\\n", + " .format(\"{:.0f}\")\\\n", " .set_table_styles([{\n", - " 'selector': '',\n", - " 'props': 'border-collapse: separate;'\n", + " \"selector\": \"\",\n", + " \"props\": \"border-collapse: separate;\"\n", " },{\n", - " 'selector': 'caption',\n", - " 'props': 'caption-side: bottom; font-size:1.3em;'\n", + " \"selector\": \"caption\",\n", + " \"props\": \"caption-side: bottom; font-size:1.3em;\"\n", " },{\n", - " 'selector': '.index_name',\n", - " 'props': 'font-style: italic; color: darkgrey; font-weight:normal;'\n", + " \"selector\": \".index_name\",\n", + " \"props\": \"font-style: italic; color: darkgrey; font-weight:normal;\"\n", " },{\n", - " 'selector': 'th:not(.index_name)',\n", - " 'props': 'background-color: #000066; color: white;'\n", + " \"selector\": \"th:not(.index_name)\",\n", + " \"props\": \"background-color: #000066; color: white;\"\n", " },{\n", - " 'selector': 'th.col_heading',\n", - " 'props': 'text-align: center;'\n", + " \"selector\": \"th.col_heading\",\n", + " \"props\": \"text-align: center;\"\n", " },{\n", - " 'selector': 'th.col_heading.level0',\n", - " 'props': 'font-size: 1.5em;'\n", + " \"selector\": \"th.col_heading.level0\",\n", + " \"props\": \"font-size: 1.5em;\"\n", " },{\n", - " 'selector': 'th.col2',\n", - " 'props': 'border-left: 1px solid white;'\n", + " \"selector\": \"th.col2\",\n", + " \"props\": \"border-left: 1px solid white;\"\n", " },{\n", - " 'selector': '.col2',\n", - " 'props': 'border-left: 1px solid #000066;'\n", + " \"selector\": \".col2\",\n", + " \"props\": \"border-left: 1px solid #000066;\"\n", " },{\n", - " 'selector': 'td',\n", - " 'props': 'text-align: center; font-weight:bold;'\n", + " \"selector\": \"td\",\n", + " \"props\": \"text-align: center; font-weight:bold;\"\n", " },{\n", - " 'selector': '.true',\n", - " 'props': 'background-color: #e6ffe6;'\n", + " \"selector\": \".true\",\n", + " \"props\": \"background-color: #e6ffe6;\"\n", " },{\n", - " 'selector': '.false',\n", - " 'props': 'background-color: #ffe6e6;'\n", + " \"selector\": \".false\",\n", + " \"props\": \"background-color: #ffe6e6;\"\n", " },{\n", - " 'selector': '.border-red',\n", - " 'props': 'border: 2px dashed red;'\n", + " \"selector\": \".border-red\",\n", + " \"props\": \"border: 2px dashed red;\"\n", " },{\n", - " 'selector': '.border-green',\n", - " 'props': 'border: 2px dashed green;'\n", + " \"selector\": \".border-green\",\n", + " \"props\": \"border: 2px dashed green;\"\n", " },{\n", - " 'selector': 'td:hover',\n", - " 'props': 'background-color: #ffffb3;'\n", + " \"selector\": \"td:hover\",\n", + " \"props\": \"background-color: #ffffb3;\"\n", " }])\\\n", - " .set_td_classes(pd.DataFrame([['true border-green', 'false', 'true', 'false border-red', '', ''],\n", - " ['false', 'true', 'false', 'true', '', '']], \n", + " .set_td_classes(pd.DataFrame([[\"true border-green\", \"false\", \"true\", \"false border-red\", \"\", \"\"],\n", + " [\"false\", \"true\", \"false\", \"true\", \"\", \"\"]],\n", " index=df.index, columns=df.columns))\\\n", " .set_caption(\"Confusion matrix for multiple cancer prediction models.\")\\\n", - " .set_tooltips(pd.DataFrame([['This model has a very strong true positive rate', '', '', \"This model's total number of false negatives is too high\", '', ''],\n", - " ['', '', '', '', '', '']], \n", + " .set_tooltips(pd.DataFrame([[\"This model has a very strong true positive rate\", \"\", \"\", \"This model's total number of false negatives is too high\", \"\", \"\"],\n", + " [\"\", \"\", \"\", \"\", \"\", \"\"]],\n", " index=df.index, columns=df.columns),\n", - " css_class='pd-tt', props=\n", - " 'visibility: hidden; position: absolute; z-index: 1; border: 1px solid #000066;'\n", - " 'background-color: white; color: #000066; font-size: 0.8em;' \n", - " 'transform: translate(0px, -24px); padding: 0.6em; border-radius: 0.5em;')\n" + " css_class=\"pd-tt\", props=\n", + " \"visibility: hidden; position: absolute; z-index: 1; border: 1px solid #000066;\"\n", + " \"background-color: white; color: #000066; font-size: 0.8em;\"\n", + " \"transform: translate(0px, -24px); padding: 0.6em; border-radius: 0.5em;\")\n" ] }, { @@ -325,7 +323,7 @@ "metadata": {}, "outputs": [], "source": [ - "s = df.style.format('{:.0f}').hide([('Random', 'Tumour'), ('Random', 'Non-Tumour')], axis=\"columns\")\n", + "s = df.style.format(\"{:.0f}\").hide([(\"Random\", \"Tumour\"), (\"Random\", \"Non-Tumour\")], axis=\"columns\")\n", "s" ] }, @@ -337,8 +335,8 @@ }, "outputs": [], "source": [ - "# Hidden cell to avoid CSS clashes and latter code upcoding previous formatting \n", - "s.set_uuid('after_hide')" + "# Hidden cell to avoid CSS clashes and latter code upcoding previous formatting\n", + "s.set_uuid(\"after_hide\")" ] }, { @@ -395,16 +393,16 @@ "outputs": [], "source": [ "cell_hover = { # for row hover use instead of \n", - " 'selector': 'td:hover',\n", - " 'props': [('background-color', '#ffffb3')]\n", + " \"selector\": \"td:hover\",\n", + " \"props\": [(\"background-color\", \"#ffffb3\")]\n", "}\n", "index_names = {\n", - " 'selector': '.index_name',\n", - " 'props': 'font-style: italic; color: darkgrey; font-weight:normal;'\n", + " \"selector\": \".index_name\",\n", + " \"props\": \"font-style: italic; color: darkgrey; font-weight:normal;\"\n", "}\n", "headers = {\n", - " 'selector': 'th:not(.index_name)',\n", - " 'props': 'background-color: #000066; color: white;'\n", + " \"selector\": \"th:not(.index_name)\",\n", + " \"props\": \"background-color: #000066; color: white;\"\n", "}\n", "s.set_table_styles([cell_hover, index_names, headers])" ] @@ -417,8 +415,8 @@ }, "outputs": [], "source": [ - "# Hidden cell to avoid CSS clashes and latter code upcoding previous formatting \n", - "s.set_uuid('after_tab_styles1')" + "# Hidden cell to avoid CSS clashes and latter code upcoding previous formatting\n", + "s.set_uuid(\"after_tab_styles1\")" ] }, { @@ -435,9 +433,9 @@ "outputs": [], "source": [ "s.set_table_styles([\n", - " {'selector': 'th.col_heading', 'props': 'text-align: center;'},\n", - " {'selector': 'th.col_heading.level0', 'props': 'font-size: 1.5em;'},\n", - " {'selector': 'td', 'props': 'text-align: center; font-weight: bold;'},\n", + " {\"selector\": \"th.col_heading\", \"props\": \"text-align: center;\"},\n", + " {\"selector\": \"th.col_heading.level0\", \"props\": \"font-size: 1.5em;\"},\n", + " {\"selector\": \"td\", \"props\": \"text-align: center; font-weight: bold;\"},\n", "], overwrite=False)" ] }, @@ -449,8 +447,8 @@ }, "outputs": [], "source": [ - "# Hidden cell to avoid CSS clashes and latter code upcoding previous formatting \n", - "s.set_uuid('after_tab_styles2')" + "# Hidden cell to avoid CSS clashes and latter code upcoding previous formatting\n", + "s.set_uuid(\"after_tab_styles2\")" ] }, { @@ -469,8 +467,8 @@ "outputs": [], "source": [ "s.set_table_styles({\n", - " ('Regression', 'Tumour'): [{'selector': 'th', 'props': 'border-left: 1px solid white'},\n", - " {'selector': 'td', 'props': 'border-left: 1px solid #000066'}]\n", + " (\"Regression\", \"Tumour\"): [{\"selector\": \"th\", \"props\": \"border-left: 1px solid white\"},\n", + " {\"selector\": \"td\", \"props\": \"border-left: 1px solid #000066\"}]\n", "}, overwrite=False, axis=0)" ] }, @@ -482,8 +480,8 @@ }, "outputs": [], "source": [ - "# Hidden cell to avoid CSS clashes and latter code upcoding previous formatting \n", - "s.set_uuid('xyz01')" + "# Hidden cell to avoid CSS clashes and latter code upcoding previous formatting\n", + "s.set_uuid(\"xyz01\")" ] }, { @@ -508,7 +506,7 @@ "outputs": [], "source": [ "out = s.set_table_attributes('class=\"my-table-cls\"').to_html()\n", - "print(out[out.find('