Skip to content

Commit 19db69e

Browse files
committed
Merge branch 'master' into refactor_offsets
2 parents 60cf932 + 5675cd8 commit 19db69e

Some content is hidden

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

80 files changed

+1343
-513
lines changed

.github/workflows/python-dev.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ on:
1010
paths-ignore:
1111
- "doc/**"
1212

13+
env:
14+
PYTEST_WORKERS: "auto"
15+
PANDAS_CI: 1
16+
PATTERN: "not slow and not network and not clipboard"
17+
COVERAGE: true
18+
1319
jobs:
1420
build:
1521
runs-on: ubuntu-latest
@@ -36,7 +42,7 @@ jobs:
3642
pip install git+https://github.com/numpy/numpy.git
3743
pip install git+https://github.com/pytest-dev/pytest.git
3844
pip install git+https://github.com/nedbat/coveragepy.git
39-
pip install cython python-dateutil pytz hypothesis pytest-xdist
45+
pip install cython python-dateutil pytz hypothesis pytest-xdist pytest-cov
4046
pip list
4147
4248
- name: Build Pandas
@@ -50,7 +56,8 @@ jobs:
5056
5157
- name: Test with pytest
5258
run: |
53-
coverage run -m pytest -m 'not slow and not network and not clipboard' pandas
59+
ci/run_tests.sh
60+
# GH 41935
5461
continue-on-error: true
5562

5663
- name: Publish test results

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ repos:
5353
types: [text]
5454
args: [--append-config=flake8/cython-template.cfg]
5555
- repo: https://github.com/PyCQA/isort
56-
rev: 5.9.0
56+
rev: 5.9.1
5757
hooks:
5858
- id: isort
5959
- repo: https://github.com/asottile/pyupgrade

asv_bench/benchmarks/algos/isin.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import numpy as np
22

3-
from pandas.compat.numpy import np_version_under1p20
3+
try:
4+
from pandas.compat import np_version_under1p20
5+
except ImportError:
6+
from pandas.compat.numpy import _np_version_under1p20 as np_version_under1p20
47

58
from pandas import (
69
Categorical,

asv_bench/benchmarks/groupby.py

+14
Original file line numberDiff line numberDiff line change
@@ -832,4 +832,18 @@ def function(values):
832832
self.grouper.agg(function, engine="cython")
833833

834834

835+
class Sample:
836+
def setup(self):
837+
N = 10 ** 3
838+
self.df = DataFrame({"a": np.zeros(N)})
839+
self.groups = np.arange(0, N)
840+
self.weights = np.ones(N)
841+
842+
def time_sample(self):
843+
self.df.groupby(self.groups).sample(n=1)
844+
845+
def time_sample_weights(self):
846+
self.df.groupby(self.groups).sample(n=1, weights=self.weights)
847+
848+
835849
from .pandas_vb_common import setup # noqa: F401 isort:skip

ci/azure/windows.yml

+2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ jobs:
1212
ENV_FILE: ci/deps/azure-windows-37.yaml
1313
CONDA_PY: "37"
1414
PATTERN: "not slow and not network"
15+
PYTEST_WORKERS: 2 # GH-42236
1516

1617
py38_np18:
1718
ENV_FILE: ci/deps/azure-windows-38.yaml
1819
CONDA_PY: "38"
1920
PATTERN: "not slow and not network and not high_memory"
21+
PYTEST_WORKERS: 2 # GH-42236
2022

2123
steps:
2224
- powershell: |

doc/source/reference/style.rst

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Styler properties
2424

2525
Styler.env
2626
Styler.template_html
27+
Styler.template_html_style
28+
Styler.template_html_table
2729
Styler.template_latex
2830
Styler.loader
2931

doc/source/user_guide/io.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -5526,13 +5526,23 @@ below and the SQLAlchemy `documentation <https://docs.sqlalchemy.org/en/latest/c
55265526
# Create your engine.
55275527
engine = create_engine("sqlite:///:memory:")
55285528
5529-
If you want to manage your own connections you can pass one of those instead:
5529+
If you want to manage your own connections you can pass one of those instead. The example below opens a
5530+
connection to the database using a Python context manager that automatically closes the connection after
5531+
the block has completed.
5532+
See the `SQLAlchemy docs <https://docs.sqlalchemy.org/en/latest/core/connections.html#basic-usage>`__
5533+
for an explanation of how the database connection is handled.
55305534

55315535
.. code-block:: python
55325536
55335537
with engine.connect() as conn, conn.begin():
55345538
data = pd.read_sql_table("data", conn)
55355539
5540+
.. warning::
5541+
5542+
When you open a connection to a database you are also responsible for closing it.
5543+
Side effects of leaving a connection open may include locking the database or
5544+
other breaking behaviour.
5545+
55365546
Writing DataFrames
55375547
''''''''''''''''''
55385548

doc/source/user_guide/style.ipynb

+53-7
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@
17801780
" Styler.loader, # the default\n",
17811781
" ])\n",
17821782
" )\n",
1783-
" template_html = env.get_template(\"myhtml.tpl\")"
1783+
" template_html_table = env.get_template(\"myhtml.tpl\")"
17841784
]
17851785
},
17861786
{
@@ -1833,14 +1833,35 @@
18331833
"outputs": [],
18341834
"source": [
18351835
"EasyStyler = Styler.from_custom_template(\"templates\", \"myhtml.tpl\")\n",
1836-
"EasyStyler(df3)"
1836+
"HTML(EasyStyler(df3).render(table_title=\"Another Title\"))"
18371837
]
18381838
},
18391839
{
18401840
"cell_type": "markdown",
18411841
"metadata": {},
18421842
"source": [
1843-
"Here's the template structure:"
1843+
"#### Template Structure\n",
1844+
"\n",
1845+
"Here's the template structure for the both the style generation template and the table generation template:"
1846+
]
1847+
},
1848+
{
1849+
"cell_type": "markdown",
1850+
"metadata": {},
1851+
"source": [
1852+
"Style template:"
1853+
]
1854+
},
1855+
{
1856+
"cell_type": "code",
1857+
"execution_count": null,
1858+
"metadata": {
1859+
"nbsphinx": "hidden"
1860+
},
1861+
"outputs": [],
1862+
"source": [
1863+
"with open(\"templates/html_style_structure.html\") as f:\n",
1864+
" style_structure = f.read()"
18441865
]
18451866
},
18461867
{
@@ -1849,10 +1870,35 @@
18491870
"metadata": {},
18501871
"outputs": [],
18511872
"source": [
1852-
"with open(\"templates/template_structure.html\") as f:\n",
1853-
" structure = f.read()\n",
1854-
" \n",
1855-
"HTML(structure)"
1873+
"HTML(style_structure)"
1874+
]
1875+
},
1876+
{
1877+
"cell_type": "markdown",
1878+
"metadata": {},
1879+
"source": [
1880+
"Table template:"
1881+
]
1882+
},
1883+
{
1884+
"cell_type": "code",
1885+
"execution_count": null,
1886+
"metadata": {
1887+
"nbsphinx": "hidden"
1888+
},
1889+
"outputs": [],
1890+
"source": [
1891+
"with open(\"templates/html_table_structure.html\") as f:\n",
1892+
" table_structure = f.read()"
1893+
]
1894+
},
1895+
{
1896+
"cell_type": "code",
1897+
"execution_count": null,
1898+
"metadata": {},
1899+
"outputs": [],
1900+
"source": [
1901+
"HTML(table_structure)"
18561902
]
18571903
},
18581904
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
This is an HTML fragment that gets included into a notebook & rst document
3+
4+
Inspired by nbconvert
5+
6+
https://github.com/jupyter/nbconvert/blob/8ac591a0b8694147d0f34bf6392594c2811c1395/docs/source/template_structure.html
7+
8+
9+
-->
10+
<style type="text/css">
11+
/* Overrides of notebook CSS for static HTML export */
12+
.template_block {
13+
background-color: hsla(120, 60%, 70%, 0.2);
14+
margin: 10px;
15+
padding: 5px;
16+
border: 1px solid hsla(120, 60%, 70%, 0.5);
17+
border-left: 2px solid black;
18+
}
19+
.template_block pre {
20+
background: transparent;
21+
padding: 0;
22+
}
23+
.big_vertical_ellipsis {
24+
font-size: 24pt;
25+
}
26+
</style>
27+
28+
<div class="template_block">before_style</div>
29+
<div class="template_block">style
30+
<pre>&lt;style type=&quot;text/css&quot;&gt;</pre>
31+
<div class="template_block">table_styles</div>
32+
<div class="template_block">before_cellstyle</div>
33+
<div class="template_block">cellstyle</div>
34+
<pre>&lt;/style&gt;</pre>
35+
</div><!-- /style -->

doc/source/user_guide/templates/template_structure.html renamed to doc/source/user_guide/templates/html_table_structure.html

-9
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@
2525
}
2626
</style>
2727

28-
<div class="template_block">before_style</div>
29-
<div class="template_block">style
30-
<pre>&lt;style type=&quot;text/css&quot;&gt;</pre>
31-
<div class="template_block">table_styles</div>
32-
<div class="template_block">before_cellstyle</div>
33-
<div class="template_block">cellstyle</div>
34-
<pre>&lt;/style&gt;</pre>
35-
</div><!-- /style -->
36-
3728
<div class="template_block" >before_table</div>
3829

3930
<div class="template_block" >table

doc/source/user_guide/templates/myhtml.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "html.tpl" %}
1+
{% extends "html_table.tpl" %}
22
{% block table %}
33
<h1>{{ table_title|default("My Table") }}</h1>
44
{{ super() }}

doc/source/whatsnew/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Version 1.3
2424
.. toctree::
2525
:maxdepth: 2
2626

27+
v1.3.1
2728
v1.3.0
2829

2930
Version 1.2

doc/source/whatsnew/v1.3.0.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _whatsnew_130:
22

3-
What's new in 1.3.0 (June ??)
4-
-----------------------------
3+
What's new in 1.3.0 (July 2, 2021)
4+
----------------------------------
55

66
These are the changes in pandas 1.3.0. See :ref:`release` for a full changelog
77
including other versions of pandas.
@@ -136,7 +136,7 @@ which has been revised and improved (:issue:`39720`, :issue:`39317`, :issue:`404
136136
- Many features of the :class:`.Styler` class are now either partially or fully usable on a DataFrame with a non-unique indexes or columns (:issue:`41143`)
137137
- One has greater control of the display through separate sparsification of the index or columns using the :ref:`new styler options <options.available>`, which are also usable via :func:`option_context` (:issue:`41142`)
138138
- Added the option ``styler.render.max_elements`` to avoid browser overload when styling large DataFrames (:issue:`40712`)
139-
- Added the method :meth:`.Styler.to_latex` (:issue:`21673`), which also allows some limited CSS conversion (:issue:`40731`)
139+
- Added the method :meth:`.Styler.to_latex` (:issue:`21673`, :issue:`42320`), which also allows some limited CSS conversion (:issue:`40731`)
140140
- Added the method :meth:`.Styler.to_html` (:issue:`13379`)
141141
- Added the method :meth:`.Styler.set_sticky` to make index and column headers permanently visible in scrolling HTML frames (:issue:`29072`)
142142

@@ -707,6 +707,8 @@ Other API changes
707707
- Added new ``engine`` and ``**engine_kwargs`` parameters to :meth:`DataFrame.to_sql` to support other future "SQL engines". Currently we still only use ``SQLAlchemy`` under the hood, but more engines are planned to be supported such as `turbodbc <https://turbodbc.readthedocs.io/en/latest/>`_ (:issue:`36893`)
708708
- Removed redundant ``freq`` from :class:`PeriodIndex` string representation (:issue:`41653`)
709709
- :meth:`ExtensionDtype.construct_array_type` is now a required method instead of an optional one for :class:`ExtensionDtype` subclasses (:issue:`24860`)
710+
- Calling ``hash`` on non-hashable pandas objects will now raise ``TypeError`` with the built-in error message (e.g. ``unhashable type: 'Series'``). Previously it would raise a custom message such as ``'Series' objects are mutable, thus they cannot be hashed``. Furthermore, ``isinstance(<Series>, abc.collections.Hashable)`` will now return ``False`` (:issue:`40013`)
711+
- :meth:`.Styler.from_custom_template` now has two new arguments for template names, and removed the old ``name``, due to template inheritance having been introducing for better parsing (:issue:`42053`). Subclassing modifications to Styler attributes are also needed.
710712

711713
.. _whatsnew_130.api_breaking.build:
712714

@@ -1231,4 +1233,4 @@ Other
12311233
Contributors
12321234
~~~~~~~~~~~~
12331235

1234-
.. contributors:: v1.2.5..v1.3.0|HEAD
1236+
.. contributors:: v1.2.5..v1.3.0

doc/source/whatsnew/v1.3.1.rst

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.. _whatsnew_131:
2+
3+
What's new in 1.3.1 (July ??, 2021)
4+
-----------------------------------
5+
6+
These are the changes in pandas 1.3.1. See :ref:`release` for a full changelog
7+
including other versions of pandas.
8+
9+
{{ header }}
10+
11+
.. ---------------------------------------------------------------------------
12+
13+
.. _whatsnew_131.regressions:
14+
15+
Fixed regressions
16+
~~~~~~~~~~~~~~~~~
17+
-
18+
-
19+
20+
.. ---------------------------------------------------------------------------
21+
22+
.. _whatsnew_131.bug_fixes:
23+
24+
Bug fixes
25+
~~~~~~~~~
26+
-
27+
-
28+
29+
.. ---------------------------------------------------------------------------
30+
31+
.. _whatsnew_131.other:
32+
33+
Other
34+
~~~~~
35+
-
36+
-
37+
38+
.. ---------------------------------------------------------------------------
39+
40+
.. _whatsnew_131.contributors:
41+
42+
Contributors
43+
~~~~~~~~~~~~
44+
45+
.. contributors:: v1.3.0..v1.3.1|HEAD

doc/source/whatsnew/v1.4.0.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for mor
8787

8888
Other API changes
8989
^^^^^^^^^^^^^^^^^
90-
-
90+
- :meth:`Index.get_indexer_for` no longer accepts keyword arguments (other than 'target'); in the past these would be silently ignored if the index was not unique (:issue:`42310`)
9191
-
9292

9393
.. ---------------------------------------------------------------------------
@@ -97,15 +97,15 @@ Other API changes
9797
Deprecations
9898
~~~~~~~~~~~~
9999
- Deprecated :meth:`Index.is_type_compatible` (:issue:`42113`)
100-
-
100+
- Deprecated ``method`` argument in :meth:`Index.get_loc`, use ``index.get_indexer([label], method=...)`` instead (:issue:`42269`)
101101

102102
.. ---------------------------------------------------------------------------
103103
104104
.. _whatsnew_140.performance:
105105

106106
Performance improvements
107107
~~~~~~~~~~~~~~~~~~~~~~~~
108-
-
108+
- Performance improvement in :meth:`.GroupBy.sample`, especially when ``weights`` argument provided (:issue:`34483`)
109109
-
110110

111111
.. ---------------------------------------------------------------------------
@@ -158,7 +158,7 @@ Interval
158158

159159
Indexing
160160
^^^^^^^^
161-
-
161+
- Bug in indexing on a :class:`Series` or :class:`DataFrame` with a :class:`DatetimeIndex` when passing a string, the return type depended on whether the index was monotonic (:issue:`24892`)
162162
-
163163

164164
Missing
@@ -173,6 +173,7 @@ MultiIndex
173173

174174
I/O
175175
^^^
176+
- Bug in :func:`read_excel` attempting to read chart sheets from .xlsx files (:issue:`41448`)
176177
-
177178
-
178179

0 commit comments

Comments
 (0)