Skip to content

Commit a81897d

Browse files
author
MomIsBestFriend
committed
Fixed merge conflicts
2 parents 316f850 + fa2aa9f commit a81897d

File tree

260 files changed

+4763
-4283
lines changed

Some content is hidden

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

260 files changed

+4763
-4283
lines changed

.pre-commit-config.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ repos:
1010
- id: flake8
1111
language: python_venv
1212
additional_dependencies: [flake8-comprehensions>=3.1.0]
13+
- id: flake8
14+
name: flake8-pyx
15+
language: python_venv
16+
files: \.(pyx|pxd)$
17+
types:
18+
- file
19+
args: [--append-config=flake8/cython.cfg]
20+
- id: flake8
21+
name: flake8-pxd
22+
language: python_venv
23+
files: \.pxi\.in$
24+
types:
25+
- file
26+
args: [--append-config=flake8/cython-template.cfg]
1327
- repo: https://github.com/pre-commit/mirrors-isort
1428
rev: v4.3.21
1529
hooks:

asv_bench/benchmarks/multiindex_object.py

+39
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,43 @@ def time_equals_non_object_index(self):
160160
self.mi_large_slow.equals(self.idx_non_object)
161161

162162

163+
class SetOperations:
164+
165+
params = [
166+
("monotonic", "non_monotonic"),
167+
("datetime", "int", "string"),
168+
("intersection", "union", "symmetric_difference"),
169+
]
170+
param_names = ["index_structure", "dtype", "method"]
171+
172+
def setup(self, index_structure, dtype, method):
173+
N = 10 ** 5
174+
level1 = range(1000)
175+
176+
level2 = date_range(start="1/1/2000", periods=N // 1000)
177+
dates_left = MultiIndex.from_product([level1, level2])
178+
179+
level2 = range(N // 1000)
180+
int_left = MultiIndex.from_product([level1, level2])
181+
182+
level2 = tm.makeStringIndex(N // 1000).values
183+
str_left = MultiIndex.from_product([level1, level2])
184+
185+
data = {
186+
"datetime": dates_left,
187+
"int": int_left,
188+
"string": str_left,
189+
}
190+
191+
if index_structure == "non_monotonic":
192+
data = {k: mi[::-1] for k, mi in data.items()}
193+
194+
data = {k: {"left": mi, "right": mi[:-1]} for k, mi in data.items()}
195+
self.left = data[dtype]["left"]
196+
self.right = data[dtype]["right"]
197+
198+
def time_operation(self, index_structure, dtype, method):
199+
getattr(self.left, method)(self.right)
200+
201+
163202
from .pandas_vb_common import setup # noqa: F401 isort:skip

ci/code_checks.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
6565
flake8 --format="$FLAKE8_FORMAT" .
6666
RET=$(($RET + $?)) ; echo $MSG "DONE"
6767

68-
MSG='Linting .pyx code' ; echo $MSG
69-
flake8 --format="$FLAKE8_FORMAT" pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411
68+
MSG='Linting .pyx and .pxd code' ; echo $MSG
69+
flake8 --format="$FLAKE8_FORMAT" pandas --append-config=flake8/cython.cfg
7070
RET=$(($RET + $?)) ; echo $MSG "DONE"
7171

72-
MSG='Linting .pxd and .pxi.in' ; echo $MSG
73-
flake8 --format="$FLAKE8_FORMAT" pandas/_libs --filename=*.pxi.in,*.pxd --select=E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
72+
MSG='Linting .pxi.in' ; echo $MSG
73+
flake8 --format="$FLAKE8_FORMAT" pandas/_libs --append-config=flake8/cython-template.cfg
7474
RET=$(($RET + $?)) ; echo $MSG "DONE"
7575

7676
echo "flake8-rst --version"
@@ -305,6 +305,10 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
305305
pandas/core/arrays/boolean.py
306306
RET=$(($RET + $?)) ; echo $MSG "DONE"
307307

308+
MSG='Doctests dtypes'; echo $MSG
309+
pytest -q --doctest-modules pandas/core/dtypes/
310+
RET=$(($RET + $?)) ; echo $MSG "DONE"
311+
308312
MSG='Doctests arrays/boolean.py' ; echo $MSG
309313
pytest -q --doctest-modules pandas/core/arrays/boolean.py
310314
RET=$(($RET + $?)) ; echo $MSG "DONE"

doc/redirects.csv

+15-15
Original file line numberDiff line numberDiff line change
@@ -271,21 +271,21 @@ generated/pandas.core.window.Expanding.skew,../reference/api/pandas.core.window.
271271
generated/pandas.core.window.Expanding.std,../reference/api/pandas.core.window.Expanding.std
272272
generated/pandas.core.window.Expanding.sum,../reference/api/pandas.core.window.Expanding.sum
273273
generated/pandas.core.window.Expanding.var,../reference/api/pandas.core.window.Expanding.var
274-
generated/pandas.core.window.Rolling.aggregate,../reference/api/pandas.core.window.Rolling.aggregate
275-
generated/pandas.core.window.Rolling.apply,../reference/api/pandas.core.window.Rolling.apply
276-
generated/pandas.core.window.Rolling.corr,../reference/api/pandas.core.window.Rolling.corr
277-
generated/pandas.core.window.Rolling.count,../reference/api/pandas.core.window.Rolling.count
278-
generated/pandas.core.window.Rolling.cov,../reference/api/pandas.core.window.Rolling.cov
279-
generated/pandas.core.window.Rolling.kurt,../reference/api/pandas.core.window.Rolling.kurt
280-
generated/pandas.core.window.Rolling.max,../reference/api/pandas.core.window.Rolling.max
281-
generated/pandas.core.window.Rolling.mean,../reference/api/pandas.core.window.Rolling.mean
282-
generated/pandas.core.window.Rolling.median,../reference/api/pandas.core.window.Rolling.median
283-
generated/pandas.core.window.Rolling.min,../reference/api/pandas.core.window.Rolling.min
284-
generated/pandas.core.window.Rolling.quantile,../reference/api/pandas.core.window.Rolling.quantile
285-
generated/pandas.core.window.Rolling.skew,../reference/api/pandas.core.window.Rolling.skew
286-
generated/pandas.core.window.Rolling.std,../reference/api/pandas.core.window.Rolling.std
287-
generated/pandas.core.window.Rolling.sum,../reference/api/pandas.core.window.Rolling.sum
288-
generated/pandas.core.window.Rolling.var,../reference/api/pandas.core.window.Rolling.var
274+
generated/pandas.core.window.Rolling.aggregate,../reference/api/pandas.core.window.rolling.Rolling.aggregate
275+
generated/pandas.core.window.Rolling.apply,../reference/api/pandas.core.window.rolling.Rolling.apply
276+
generated/pandas.core.window.Rolling.corr,../reference/api/pandas.core.window.rolling.Rolling.corr
277+
generated/pandas.core.window.Rolling.count,../reference/api/pandas.core.window.rolling.Rolling.count
278+
generated/pandas.core.window.Rolling.cov,../reference/api/pandas.core.window.rolling.Rolling.cov
279+
generated/pandas.core.window.Rolling.kurt,../reference/api/pandas.core.window.rolling.Rolling.kurt
280+
generated/pandas.core.window.Rolling.max,../reference/api/pandas.core.window.rolling.Rolling.max
281+
generated/pandas.core.window.Rolling.mean,../reference/api/pandas.core.window.rolling.Rolling.mean
282+
generated/pandas.core.window.Rolling.median,../reference/api/pandas.core.window.rolling.Rolling.median
283+
generated/pandas.core.window.Rolling.min,../reference/api/pandas.core.window.rolling.Rolling.min
284+
generated/pandas.core.window.Rolling.quantile,../reference/api/pandas.core.window.rolling.Rolling.quantile
285+
generated/pandas.core.window.Rolling.skew,../reference/api/pandas.core.window.rolling.Rolling.skew
286+
generated/pandas.core.window.Rolling.std,../reference/api/pandas.core.window.rolling.Rolling.std
287+
generated/pandas.core.window.Rolling.sum,../reference/api/pandas.core.window.rolling.Rolling.sum
288+
generated/pandas.core.window.Rolling.var,../reference/api/pandas.core.window.rolling.Rolling.var
289289
generated/pandas.core.window.Window.mean,../reference/api/pandas.core.window.Window.mean
290290
generated/pandas.core.window.Window.sum,../reference/api/pandas.core.window.Window.sum
291291
generated/pandas.crosstab,../reference/api/pandas.crosstab

doc/source/development/code_style.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ For example:
119119
.. code-block:: python
120120
121121
value = str
122-
f"Unknown recived value, got: {repr(value)}"
122+
f"Unknown received value, got: {repr(value)}"
123123
124124
**Good:**
125125

126126
.. code-block:: python
127127
128128
value = str
129-
f"Unknown recived type, got: '{type(value).__name__}'"
129+
f"Unknown received type, got: '{type(value).__name__}'"
130130
131131
132132
Imports (aim for absolute)
@@ -135,11 +135,11 @@ Imports (aim for absolute)
135135
In Python 3, absolute imports are recommended. In absolute import doing something
136136
like ``import string`` will import the string module rather than ``string.py``
137137
in the same directory. As much as possible, you should try to write out
138-
absolute imports that show the whole import chain from toplevel pandas.
138+
absolute imports that show the whole import chain from top-level pandas.
139139

140-
Explicit relative imports are also supported in Python 3. But it is not
141-
recommended to use it. Implicit relative imports should never be used
142-
and is removed in Python 3.
140+
Explicit relative imports are also supported in Python 3 but it is not
141+
recommended to use them. Implicit relative imports should never be used
142+
and are removed in Python 3.
143143

144144
For example:
145145

doc/source/development/contributing_docstring.rst

+11-16
Original file line numberDiff line numberDiff line change
@@ -937,33 +937,31 @@ classes. This helps us keep docstrings consistent, while keeping things clear
937937
for the user reading. It comes at the cost of some complexity when writing.
938938

939939
Each shared docstring will have a base template with variables, like
940-
``%(klass)s``. The variables filled in later on using the ``Substitution``
941-
decorator. Finally, docstrings can be appended to with the ``Appender``
942-
decorator.
940+
``{klass}``. The variables filled in later on using the ``doc`` decorator.
941+
Finally, docstrings can also be appended to with the ``doc`` decorator.
943942

944943
In this example, we'll create a parent docstring normally (this is like
945944
``pandas.core.generic.NDFrame``. Then we'll have two children (like
946945
``pandas.core.series.Series`` and ``pandas.core.frame.DataFrame``). We'll
947-
substitute the children's class names in this docstring.
946+
substitute the class names in this docstring.
948947

949948
.. code-block:: python
950949
951950
class Parent:
951+
@doc(klass="Parent")
952952
def my_function(self):
953-
"""Apply my function to %(klass)s."""
953+
"""Apply my function to {klass}."""
954954
...
955955
956956
957957
class ChildA(Parent):
958-
@Substitution(klass="ChildA")
959-
@Appender(Parent.my_function.__doc__)
958+
@doc(Parent.my_function, klass="ChildA")
960959
def my_function(self):
961960
...
962961
963962
964963
class ChildB(Parent):
965-
@Substitution(klass="ChildB")
966-
@Appender(Parent.my_function.__doc__)
964+
@doc(Parent.my_function, klass="ChildB")
967965
def my_function(self):
968966
...
969967
@@ -972,18 +970,16 @@ The resulting docstrings are
972970
.. code-block:: python
973971
974972
>>> print(Parent.my_function.__doc__)
975-
Apply my function to %(klass)s.
973+
Apply my function to Parent.
976974
>>> print(ChildA.my_function.__doc__)
977975
Apply my function to ChildA.
978976
>>> print(ChildB.my_function.__doc__)
979977
Apply my function to ChildB.
980978
981-
Notice two things:
979+
Notice:
982980

983981
1. We "append" the parent docstring to the children docstrings, which are
984982
initially empty.
985-
2. Python decorators are applied inside out. So the order is Append then
986-
Substitution, even though Substitution comes first in the file.
987983

988984
Our files will often contain a module-level ``_shared_doc_kwargs`` with some
989985
common substitution values (things like ``klass``, ``axes``, etc).
@@ -992,14 +988,13 @@ You can substitute and append in one shot with something like
992988

993989
.. code-block:: python
994990
995-
@Appender(template % _shared_doc_kwargs)
991+
@doc(template, **_shared_doc_kwargs)
996992
def my_function(self):
997993
...
998994
999995
where ``template`` may come from a module-level ``_shared_docs`` dictionary
1000996
mapping function names to docstrings. Wherever possible, we prefer using
1001-
``Appender`` and ``Substitution``, since the docstring-writing processes is
1002-
slightly closer to normal.
997+
``doc``, since the docstring-writing processes is slightly closer to normal.
1003998

1004999
See ``pandas.core.generic.NDFrame.fillna`` for an example template, and
10051000
``pandas.core.series.Series.fillna`` and ``pandas.core.generic.frame.fillna``

doc/source/getting_started/10min.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ will be completed:
7070
df2.abs df2.boxplot
7171
df2.add df2.C
7272
df2.add_prefix df2.clip
73-
df2.add_suffix df2.clip_lower
74-
df2.align df2.clip_upper
75-
df2.all df2.columns
73+
df2.add_suffix df2.columns
74+
df2.align df2.copy
75+
df2.all df2.count
7676
df2.any df2.combine
77-
df2.append df2.combine_first
78-
df2.apply df2.consolidate
79-
df2.applymap
80-
df2.D
77+
df2.append df2.D
78+
df2.apply df2.describe
79+
df2.applymap df2.diff
80+
df2.B df2.duplicated
8181

8282
As you can see, the columns ``A``, ``B``, ``C``, and ``D`` are automatically
83-
tab completed. ``E`` is there as well; the rest of the attributes have been
83+
tab completed. ``E`` and ``F`` are there as well; the rest of the attributes have been
8484
truncated for brevity.
8585

8686
Viewing data

doc/source/getting_started/install.rst

+17
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,23 @@ The commands in this table will install pandas for Python 3 from your distributi
163163
to get the newest version of pandas, it's recommended to install using the ``pip`` or ``conda``
164164
methods described above.
165165

166+
Handling ImportErrors
167+
~~~~~~~~~~~~~~~~~~~~~~
168+
169+
If you encounter an ImportError, it usually means that Python couldn't find pandas in the list of available
170+
libraries. Python internally has a list of directories it searches through, to find packages. You can
171+
obtain these directories with::
172+
173+
import sys
174+
sys.path
175+
176+
One way you could be encountering this error is if you have multiple Python installations on your system
177+
and you don't have pandas installed in the Python installation you're currently using.
178+
In Linux/Mac you can run ``which python`` on your terminal and it will tell you which Python installation you're
179+
using. If it's something like "/usr/bin/python", you're using the Python from the system, which is not recommended.
180+
181+
It is highly recommended to use ``conda``, for quick installation and for package and dependency updates.
182+
You can find simple installation instructions for pandas in this document: `installation instructions </getting_started.html>`.
166183

167184
Installing from source
168185
~~~~~~~~~~~~~~~~~~~~~~

doc/source/user_guide/boolean.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
.. _boolean:
1010

1111
**************************
12-
Nullable Boolean Data Type
12+
Nullable Boolean data type
1313
**************************
1414

1515
.. versionadded:: 1.0.0

doc/source/whatsnew/v1.0.2.rst

+18-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Fixed regressions
1616
~~~~~~~~~~~~~~~~~
1717

1818
- Fixed regression in :meth:`DataFrame.to_excel` when ``columns`` kwarg is passed (:issue:`31677`)
19+
- Fixed regression in :meth:`Series.align` when ``other`` is a DataFrame and ``method`` is not None (:issue:`31785`)
20+
- Fixed regression in :meth:`pandas.core.groupby.RollingGroupby.apply` where the ``raw`` parameter was ignored (:issue:`31754`)
21+
- Fixed regression in :meth:`rolling(..).corr() <pandas.core.window.Rolling.corr>` when using a time offset (:issue:`31789`)
1922
-
2023

2124
.. ---------------------------------------------------------------------------
@@ -25,8 +28,21 @@ Fixed regressions
2528
Bug fixes
2629
~~~~~~~~~
2730

28-
-
29-
-
31+
**Categorical**
32+
33+
- Fixed bug where :meth:`Categorical.from_codes` improperly raised a ``ValueError`` when passed nullable integer codes. (:issue:`31779`)
34+
35+
**I/O**
36+
37+
- Using ``pd.NA`` with :meth:`DataFrame.to_json` now correctly outputs a null value instead of an empty object (:issue:`31615`)
38+
- Fixed bug in parquet roundtrip with nullable unsigned integer dtypes (:issue:`31896`).
39+
40+
41+
42+
**Experimental dtypes**
43+
44+
- Fix bug in :meth:`DataFrame.convert_dtypes` for columns that were already using the ``"string"`` dtype (:issue:`31731`).
45+
- Fixed bug in setting values using a slice indexer with string dtype (:issue:`31772`)
3046

3147
.. ---------------------------------------------------------------------------
3248

0 commit comments

Comments
 (0)