Skip to content

Commit 24223e5

Browse files
committed
fixup
2 parents 13793a2 + fd38824 commit 24223e5

File tree

118 files changed

+1957
-916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1957
-916
lines changed

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ repos:
1919
types_or: [python, rst, markdown]
2020
files: ^(pandas|doc)/
2121
- repo: https://github.com/pre-commit/pre-commit-hooks
22-
rev: v3.4.0
22+
rev: v4.0.1
2323
hooks:
2424
- id: debug-statements
2525
- id: end-of-file-fixer
2626
exclude: \.txt$
2727
- id: trailing-whitespace
2828
- repo: https://github.com/cpplint/cpplint
29-
rev: f7061b1 # the latest tag does not have the hook
29+
rev: 1.5.5
3030
hooks:
3131
- id: cpplint
3232
# We don't lint all C files because we don't want to lint any that are built
@@ -57,7 +57,7 @@ repos:
5757
hooks:
5858
- id: isort
5959
- repo: https://github.com/asottile/pyupgrade
60-
rev: v2.12.0
60+
rev: v2.18.3
6161
hooks:
6262
- id: pyupgrade
6363
args: [--py37-plus]
@@ -72,7 +72,7 @@ repos:
7272
types: [text] # overwrite types: [rst]
7373
types_or: [python, rst]
7474
- repo: https://github.com/asottile/yesqa
75-
rev: v1.2.2
75+
rev: v1.2.3
7676
hooks:
7777
- id: yesqa
7878
additional_dependencies:

ci/deps/actions-38-numpydev.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212

1313
# pandas dependencies
1414
- pytz
15-
- pip=20.2
15+
- pip
1616
- pip:
1717
- cython==0.29.21 # GH#34014
1818
- "git+git://github.com/dateutil/dateutil.git"

doc/source/_static/style/tg_ax0.png

12.7 KB
Loading
13.2 KB
Loading
13.4 KB
Loading
13.3 KB
Loading
12.5 KB
Loading

doc/source/_static/style/tg_gmap.png

12.3 KB
Loading

doc/source/reference/style.rst

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Builtin styles
5656
Styler.highlight_min
5757
Styler.highlight_between
5858
Styler.background_gradient
59+
Styler.text_gradient
5960
Styler.bar
6061

6162
Style export and import

doc/source/user_guide/groupby.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ instance method on each data group. This is pretty easy to do by passing lambda
10001000
functions:
10011001

10021002
.. ipython:: python
1003+
:okwarning:
10031004
10041005
grouped = df.groupby("A")
10051006
grouped.agg(lambda x: x.std())
@@ -1009,6 +1010,7 @@ arguments. Using a bit of metaprogramming cleverness, GroupBy now has the
10091010
ability to "dispatch" method calls to the groups:
10101011

10111012
.. ipython:: python
1013+
:okwarning:
10121014
10131015
grouped.std()
10141016

doc/source/user_guide/io.rst

+37-10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The pandas I/O API is a set of top level ``reader`` functions accessed like
2222
text;Fixed-Width Text File;:ref:`read_fwf<io.fwf_reader>`
2323
text;`JSON <https://www.json.org/>`__;:ref:`read_json<io.json_reader>`;:ref:`to_json<io.json_writer>`
2424
text;`HTML <https://en.wikipedia.org/wiki/HTML>`__;:ref:`read_html<io.read_html>`;:ref:`to_html<io.html>`
25+
text;`LaTeX <https://en.wikipedia.org/wiki/LaTeX>`__;;:ref:`Styler.to_latex<io.latex>`
2526
text;`XML <https://www.w3.org/standards/xml/core>`__;:ref:`read_xml<io.read_xml>`;:ref:`to_xml<io.xml>`
2627
text; Local clipboard;:ref:`read_clipboard<io.clipboard>`;:ref:`to_clipboard<io.clipboard>`
2728
binary;`MS Excel <https://en.wikipedia.org/wiki/Microsoft_Excel>`__;:ref:`read_excel<io.excel_reader>`;:ref:`to_excel<io.excel_writer>`
@@ -1896,7 +1897,7 @@ Writing in ISO date format:
18961897
18971898
dfd = pd.DataFrame(np.random.randn(5, 2), columns=list("AB"))
18981899
dfd["date"] = pd.Timestamp("20130101")
1899-
dfd = dfd.sort_index(1, ascending=False)
1900+
dfd = dfd.sort_index(axis=1, ascending=False)
19001901
json = dfd.to_json(date_format="iso")
19011902
json
19021903
@@ -2830,7 +2831,42 @@ parse HTML tables in the top-level pandas io function ``read_html``.
28302831
.. |lxml| replace:: **lxml**
28312832
.. _lxml: https://lxml.de
28322833

2834+
.. _io.latex:
28332835

2836+
LaTeX
2837+
-----
2838+
2839+
.. versionadded:: 1.3.0
2840+
2841+
Currently there are no methods to read from LaTeX, only output methods.
2842+
2843+
Writing to LaTeX files
2844+
''''''''''''''''''''''
2845+
2846+
.. note::
2847+
2848+
DataFrame *and* Styler objects currently have a ``to_latex`` method. We recommend
2849+
using the `Styler.to_latex() <../reference/api/pandas.io.formats.style.Styler.to_latex.rst>`__ method
2850+
over `DataFrame.to_latex() <../reference/api/pandas.DataFrame.to_latex.rst>`__ due to the former's greater flexibility with
2851+
conditional styling, and the latter's possible future deprecation.
2852+
2853+
Review the documentation for `Styler.to_latex <../reference/api/pandas.io.formats.style.Styler.to_latex.rst>`__,
2854+
which gives examples of conditional styling and explains the operation of its keyword
2855+
arguments.
2856+
2857+
For simple application the following pattern is sufficient.
2858+
2859+
.. ipython:: python
2860+
2861+
df = pd.DataFrame([[1, 2], [3, 4]], index=["a", "b"], columns=["c", "d"])
2862+
print(df.style.to_latex())
2863+
2864+
To format values before output, chain the `Styler.format <../reference/api/pandas.io.formats.style.Styler.format.rst>`__
2865+
method.
2866+
2867+
.. ipython:: python
2868+
2869+
print(df.style.format("{}").to_latex())
28342870
28352871
XML
28362872
---
@@ -3648,15 +3684,6 @@ one can pass an :class:`~pandas.io.excel.ExcelWriter`.
36483684
df1.to_excel(writer, sheet_name="Sheet1")
36493685
df2.to_excel(writer, sheet_name="Sheet2")
36503686
3651-
.. note::
3652-
3653-
Wringing a little more performance out of ``read_excel``
3654-
Internally, Excel stores all numeric data as floats. Because this can
3655-
produce unexpected behavior when reading in data, pandas defaults to trying
3656-
to convert integers to floats if it doesn't lose information (``1.0 -->
3657-
1``). You can pass ``convert_float=False`` to disable this behavior, which
3658-
may give a slight performance improvement.
3659-
36603687
.. _io.excel_writing_buffer:
36613688

36623689
Writing Excel files to memory

doc/source/user_guide/style.ipynb

+19-5
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,8 @@
10121012
" - [.highlight_min][minfunc] and [.highlight_max][maxfunc]: for use with identifying extremeties in data.\n",
10131013
" - [.highlight_between][betweenfunc] and [.highlight_quantile][quantilefunc]: for use with identifying classes within data.\n",
10141014
" - [.background_gradient][bgfunc]: a flexible method for highlighting cells based or their, or other, values on a numeric scale.\n",
1015-
" - [.bar][barfunc]: to display mini-charts within cell backgrounds.\n",
1015+
" - [.text_gradient][textfunc]: similar method for highlighting text based on their, or other, values on a numeric scale.\n",
1016+
" - [.bar][barfunc]: to display mini-charts within cell backgrounds.\n",
10161017
" \n",
10171018
"The individual documentation on each function often gives more examples of their arguments.\n",
10181019
"\n",
@@ -1022,6 +1023,7 @@
10221023
"[betweenfunc]: ../reference/api/pandas.io.formats.style.Styler.highlight_between.rst\n",
10231024
"[quantilefunc]: ../reference/api/pandas.io.formats.style.Styler.highlight_quantile.rst\n",
10241025
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst\n",
1026+
"[textfunc]: ../reference/api/pandas.io.formats.style.Styler.text_gradient.rst\n",
10251027
"[barfunc]: ../reference/api/pandas.io.formats.style.Styler.bar.rst"
10261028
]
10271029
},
@@ -1098,14 +1100,14 @@
10981100
"cell_type": "markdown",
10991101
"metadata": {},
11001102
"source": [
1101-
"### Background Gradient"
1103+
"### Background Gradient and Text Gradient"
11021104
]
11031105
},
11041106
{
11051107
"cell_type": "markdown",
11061108
"metadata": {},
11071109
"source": [
1108-
"You can create \"heatmaps\" with the `background_gradient` method. These require matplotlib, and we'll use [Seaborn](https://stanford.edu/~mwaskom/software/seaborn/) to get a nice colormap."
1110+
"You can create \"heatmaps\" with the `background_gradient` and `text_gradient` methods. These require matplotlib, and we'll use [Seaborn](https://stanford.edu/~mwaskom/software/seaborn/) to get a nice colormap."
11091111
]
11101112
},
11111113
{
@@ -1120,19 +1122,31 @@
11201122
"df2.style.background_gradient(cmap=cm)"
11211123
]
11221124
},
1125+
{
1126+
"cell_type": "code",
1127+
"execution_count": null,
1128+
"metadata": {},
1129+
"outputs": [],
1130+
"source": [
1131+
"df2.style.text_gradient(cmap=cm)"
1132+
]
1133+
},
11231134
{
11241135
"cell_type": "markdown",
11251136
"metadata": {},
11261137
"source": [
1127-
"[.background_gradient][bgfunc] has a number of keyword arguments to customise the gradients and colors. See its documentation.\n",
1138+
"[.background_gradient][bgfunc] and [.text_gradient][textfunc] have a number of keyword arguments to customise the gradients and colors. See the documentation.\n",
11281139
"\n",
1129-
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst"
1140+
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst\n",
1141+
"[textfunc]: ../reference/api/pandas.io.formats.style.Styler.text_gradient.rst"
11301142
]
11311143
},
11321144
{
11331145
"cell_type": "markdown",
11341146
"metadata": {},
11351147
"source": [
1148+
"### Set properties\n",
1149+
"\n",
11361150
"Use `Styler.set_properties` when the style doesn't actually depend on the values. This is just a simple wrapper for `.applymap` where the function returns the same properties for all cells."
11371151
]
11381152
},

0 commit comments

Comments
 (0)