Skip to content

Commit add8b51

Browse files
authored
Merge branch 'master' into Fix_support_for_matplotlib_s_constrained_layout_25261
2 parents 6b680bc + 421fb8d commit add8b51

File tree

226 files changed

+6949
-5629
lines changed

Some content is hidden

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

226 files changed

+6949
-5629
lines changed

.github/ISSUE_TEMPLATE/documentation_improvement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ labels: "Docs, Needs Triage"
99

1010
#### Location of the documentation
1111

12-
[this should provide the location of the documentation, e.g. "pandas.read_csv" or the URL of the documentation, e.g. "https://dev.pandas.io/docs/reference/api/pandas.read_csv.html"]
12+
[this should provide the location of the documentation, e.g. "pandas.read_csv" or the URL of the documentation, e.g. "https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html"]
1313

1414
**Note**: You can check the latest versions of the docs on `master` [here](https://pandas.pydata.org/docs/dev/).
1515

.pre-commit-config.yaml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ repos:
6060
entry: |
6161
(?x)
6262
# Check for imports from pandas.core.common instead of `import pandas.core.common as com`
63-
from\ pandas\.core\.common\ import|
64-
from\ pandas\.core\ import\ common|
63+
from\ pandas\.core\.common\ import
64+
|from\ pandas\.core\ import\ common
6565
6666
# Check for imports from collections.abc instead of `from collections import abc`
67-
from\ collections\.abc\ import
67+
|from\ collections\.abc\ import
6868
6969
- id: non-standard-numpy.random-related-imports
7070
name: Check for non-standard numpy.random-related imports excluding pandas/_testing.py
@@ -73,24 +73,24 @@ repos:
7373
entry: |
7474
(?x)
7575
# Check for imports from np.random.<method> instead of `from numpy import random` or `from numpy.random import <method>`
76-
from\ numpy\ import\ random|
77-
from\ numpy.random\ import
76+
from\ numpy\ import\ random
77+
|from\ numpy.random\ import
7878
types: [python]
7979
- id: non-standard-imports-in-tests
8080
name: Check for non-standard imports in test suite
8181
language: pygrep
8282
entry: |
8383
(?x)
8484
# Check for imports from pandas._testing instead of `import pandas._testing as tm`
85-
from\ pandas\._testing\ import|
86-
from\ pandas\ import\ _testing\ as\ tm|
85+
from\ pandas\._testing\ import
86+
|from\ pandas\ import\ _testing\ as\ tm
8787
8888
# No direct imports from conftest
89-
conftest\ import|
90-
import\ conftest
89+
|conftest\ import
90+
|import\ conftest
9191
9292
# Check for use of pandas.testing instead of tm
93-
pd\.testing\.
93+
|pd\.testing\.
9494
types: [python]
9595
files: ^pandas/tests/
9696
- id: incorrect-code-directives
@@ -135,7 +135,7 @@ repos:
135135
files: ^pandas/tests/
136136
- id: FrameOrSeriesUnion
137137
name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
138-
entry: Union\[.*(Series.*DataFrame|DataFrame.*Series).*\]
138+
entry: Union\[.*(Series,.*DataFrame|DataFrame,.*Series).*\]
139139
language: pygrep
140140
types: [python]
141141
exclude: ^pandas/_typing\.py$
@@ -148,9 +148,8 @@ repos:
148148
name: Check for outdated annotation syntax and missing error codes
149149
entry: |
150150
(?x)
151-
\#\ type:\ (?!ignore)|
152-
\#\ type:\s?ignore(?!\[)|
153-
\)\ ->\ \"
151+
\#\ type:\ (?!ignore)
152+
|\#\ type:\s?ignore(?!\[)
154153
language: pygrep
155154
types: [python]
156155
- id: np-bool
@@ -166,9 +165,15 @@ repos:
166165
files: ^pandas/tests/
167166
exclude: |
168167
(?x)^
169-
pandas/tests/io/excel/test_writers\.py|
170-
pandas/tests/io/pytables/common\.py|
171-
pandas/tests/io/pytables/test_store\.py$
168+
pandas/tests/io/excel/test_writers\.py
169+
|pandas/tests/io/pytables/common\.py
170+
|pandas/tests/io/pytables/test_store\.py$
171+
- id: no-pandas-api-types
172+
name: Check code for instances of pd.api.types
173+
entry: (pd|pandas)\.api\.types\.
174+
language: pygrep
175+
types: [python]
176+
files: ^pandas/tests/
172177
- repo: https://github.com/asottile/yesqa
173178
rev: v1.2.2
174179
hooks:
@@ -184,4 +189,9 @@ repos:
184189
hooks:
185190
- id: codespell
186191
types_or: [python, rst, markdown]
187-
files: ^pandas/core/
192+
files: ^pandas/
193+
exclude: ^pandas/tests/
194+
- repo: https://github.com/MarcoGorelli/no-string-hints
195+
rev: v0.1.6
196+
hooks:
197+
- id: no-string-hints

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<img src="https://dev.pandas.io/static/img/pandas.svg"><br>
2+
<img src="https://pandas.pydata.org/static/img/pandas.svg"><br>
33
</div>
44

55
-----------------

asv_bench/benchmarks/indexing.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,20 @@ def time_loc_list(self, monotonic):
243243
monotonic.loc[80000:]
244244

245245

246+
class DatetimeIndexIndexing:
247+
def setup(self):
248+
dti = date_range("2016-01-01", periods=10000, tz="US/Pacific")
249+
dti2 = dti.tz_convert("UTC")
250+
self.dti = dti
251+
self.dti2 = dti2
252+
253+
def time_get_indexer_mismatched_tz(self):
254+
# reached via e.g.
255+
# ser = Series(range(len(dti)), index=dti)
256+
# ser[dti2]
257+
self.dti.get_indexer(self.dti2)
258+
259+
246260
class CategoricalIndexIndexing:
247261

248262
params = ["monotonic_incr", "monotonic_decr", "non_monotonic"]

asv_bench/benchmarks/io/csv.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,54 @@ def time_frame(self, obs):
7676
self.data.to_csv(self.fname)
7777

7878

79+
class ToCSVIndexes(BaseIO):
80+
81+
fname = "__test__.csv"
82+
83+
@staticmethod
84+
def _create_df(rows, cols):
85+
index_cols = {
86+
"index1": np.random.randint(0, rows, rows),
87+
"index2": np.full(rows, 1, dtype=np.int),
88+
"index3": np.full(rows, 1, dtype=np.int),
89+
}
90+
data_cols = {
91+
f"col{i}": np.random.uniform(0, 100000.0, rows) for i in range(cols)
92+
}
93+
df = DataFrame({**index_cols, **data_cols})
94+
return df
95+
96+
def setup(self):
97+
ROWS = 100000
98+
COLS = 5
99+
# For tests using .head(), create an initial dataframe with this many times
100+
# more rows
101+
HEAD_ROW_MULTIPLIER = 10
102+
103+
self.df_standard_index = self._create_df(ROWS, COLS)
104+
105+
self.df_custom_index_then_head = (
106+
self._create_df(ROWS * HEAD_ROW_MULTIPLIER, COLS)
107+
.set_index(["index1", "index2", "index3"])
108+
.head(ROWS)
109+
)
110+
111+
self.df_head_then_custom_index = (
112+
self._create_df(ROWS * HEAD_ROW_MULTIPLIER, COLS)
113+
.head(ROWS)
114+
.set_index(["index1", "index2", "index3"])
115+
)
116+
117+
def time_standard_index(self):
118+
self.df_standard_index.to_csv(self.fname)
119+
120+
def time_multiindex(self):
121+
self.df_head_then_custom_index.to_csv(self.fname)
122+
123+
def time_head_of_multiindex(self):
124+
self.df_custom_index_then_head.to_csv(self.fname)
125+
126+
79127
class StringIORewind:
80128
def data(self, stringio_object):
81129
stringio_object.seek(0)

asv_bench/benchmarks/reshape.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pandas as pd
77
from pandas import DataFrame, MultiIndex, date_range, melt, wide_to_long
8+
from pandas.api.types import CategoricalDtype
89

910

1011
class Melt:
@@ -196,7 +197,7 @@ def setup(self):
196197
categories = list(string.ascii_letters[:12])
197198
s = pd.Series(
198199
np.random.choice(categories, size=1000000),
199-
dtype=pd.api.types.CategoricalDtype(categories),
200+
dtype=CategoricalDtype(categories),
200201
)
201202
self.s = s
202203

doc/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164

165165
# The language for content autogenerated by Sphinx. Refer to documentation
166166
# for a list of supported languages.
167-
# language = None
167+
language = "en"
168168

169169
# There are two options for replacing |today|: either, you set today to some
170170
# non-false value, then it is used:

doc/source/getting_started/comparison/comparison_with_spreadsheets.rst

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ Both `Excel <https://support.microsoft.com/en-us/office/import-data-from-externa
8989
and :ref:`pandas <10min_tut_02_read_write>` can import data from various sources in various
9090
formats.
9191

92-
Excel files
93-
'''''''''''
94-
95-
Excel opens `various Excel file formats <https://support.microsoft.com/en-us/office/file-formats-that-are-supported-in-excel-0943ff2c-6014-4e8d-aaea-b83d51d46247>`_
96-
by double-clicking them, or using `the Open menu <https://support.microsoft.com/en-us/office/open-files-from-the-file-menu-97f087d8-3136-4485-8e86-c5b12a8c4176>`_.
97-
In pandas, you use :ref:`special methods for reading and writing from/to Excel files <io.excel>`.
98-
9992
CSV
10093
'''
10194

@@ -125,6 +118,27 @@ would be:
125118
# alternatively, read_table is an alias to read_csv with tab delimiter
126119
tips = pd.read_table("tips.csv", header=None)
127120
121+
Excel files
122+
'''''''''''
123+
124+
Excel opens `various Excel file formats <https://support.microsoft.com/en-us/office/file-formats-that-are-supported-in-excel-0943ff2c-6014-4e8d-aaea-b83d51d46247>`_
125+
by double-clicking them, or using `the Open menu <https://support.microsoft.com/en-us/office/open-files-from-the-file-menu-97f087d8-3136-4485-8e86-c5b12a8c4176>`_.
126+
In pandas, you use :ref:`special methods for reading and writing from/to Excel files <io.excel>`.
127+
128+
Let's first :ref:`create a new Excel file <io.excel_writer>` based on the ``tips`` dataframe in the above example:
129+
130+
.. code-block:: python
131+
132+
tips.to_excel("./tips.xlsx")
133+
134+
Should you wish to subsequently access the data in the ``tips.xlsx`` file, you can read it into your module using
135+
136+
.. code-block:: python
137+
138+
tips_df = pd.read_excel("./tips.xlsx", index_col=0)
139+
140+
You have just read in an Excel file using pandas!
141+
128142

129143
Limiting output
130144
~~~~~~~~~~~~~~~

doc/source/user_guide/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2853,7 +2853,7 @@ See the :ref:`cookbook<cookbook.excel>` for some advanced strategies.
28532853
The `xlrd <https://xlrd.readthedocs.io/en/latest/>`__ package is now only for reading
28542854
old-style ``.xls`` files.
28552855

2856-
Previously, the default argument ``engine=None`` to :func:`~pandas.read_excel`
2856+
Before pandas 1.2.0, the default argument ``engine=None`` to :func:`~pandas.read_excel`
28572857
would result in using the ``xlrd`` engine in many cases, including new
28582858
Excel 2007+ (``.xlsx``) files.
28592859
If `openpyxl <https://openpyxl.readthedocs.io/en/stable/>`__ is installed,

0 commit comments

Comments
 (0)