Skip to content

Commit 4d77b31

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix_convert_dtypes_bool
2 parents 510369f + 37659d4 commit 4d77b31

Some content is hidden

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

82 files changed

+1972
-1442
lines changed

asv_bench/benchmarks/arithmetic.py

+30
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,36 @@ def time_frame_op_with_scalar(self, dtype, scalar, op):
5050
op(self.df, scalar)
5151

5252

53+
class MixedFrameWithSeriesAxis0:
54+
params = [
55+
[
56+
"eq",
57+
"ne",
58+
"lt",
59+
"le",
60+
"ge",
61+
"gt",
62+
"add",
63+
"sub",
64+
"div",
65+
"floordiv",
66+
"mul",
67+
"pow",
68+
]
69+
]
70+
param_names = ["opname"]
71+
72+
def setup(self, opname):
73+
arr = np.arange(10 ** 6).reshape(100, -1)
74+
df = DataFrame(arr)
75+
df["C"] = 1.0
76+
self.df = df
77+
self.ser = df[0]
78+
79+
def time_frame_op_with_series_axis0(self, opname):
80+
getattr(self.df, opname)(self.ser, axis=0)
81+
82+
5383
class Ops:
5484

5585
params = [[True, False], ["default", 1]]

ci/code_checks.sh

+15-5
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,6 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
267267
-k"-nonzero -reindex -searchsorted -to_dict"
268268
RET=$(($RET + $?)) ; echo $MSG "DONE"
269269

270-
MSG='Doctests generic.py' ; echo $MSG
271-
pytest -q --doctest-modules pandas/core/generic.py \
272-
-k"-_set_axis_name -_xs -describe -groupby -interpolate -pct_change -pipe -reindex -reindex_axis -to_json -transpose -values -xs -to_clipboard"
273-
RET=$(($RET + $?)) ; echo $MSG "DONE"
274-
275270
MSG='Doctests groupby.py' ; echo $MSG
276271
pytest -q --doctest-modules pandas/core/groupby/groupby.py -k"-cumcount -describe -pipe"
277272
RET=$(($RET + $?)) ; echo $MSG "DONE"
@@ -311,6 +306,17 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
311306
pytest -q --doctest-modules pandas/core/arrays/boolean.py
312307
RET=$(($RET + $?)) ; echo $MSG "DONE"
313308

309+
MSG='Doctests base.py' ; echo $MSG
310+
pytest -q --doctest-modules pandas/core/base.py
311+
RET=$(($RET + $?)) ; echo $MSG "DONE"
312+
313+
MSG='Doctests construction.py' ; echo $MSG
314+
pytest -q --doctest-modules pandas/core/construction.py
315+
RET=$(($RET + $?)) ; echo $MSG "DONE"
316+
317+
MSG='Doctests generic.py' ; echo $MSG
318+
pytest -q --doctest-modules pandas/core/generic.py
319+
RET=$(($RET + $?)) ; echo $MSG "DONE"
314320
fi
315321

316322
### DOCSTRINGS ###
@@ -320,6 +326,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
320326
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL03,GL04,GL05,GL06,GL07,GL09,GL10,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA02,SA03,SA05
321327
RET=$(($RET + $?)) ; echo $MSG "DONE"
322328

329+
MSG='Validate correct capitalization among titles in documentation' ; echo $MSG
330+
$BASE_DIR/scripts/validate_rst_title_capitalization.py $BASE_DIR/doc/source/development/contributing.rst
331+
RET=$(($RET + $?)) ; echo $MSG "DONE"
332+
323333
fi
324334

325335
### DEPENDENCIES ###

doc/redirects.csv

+19-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,25 @@ internals,development/internals
4949
# api moved function
5050
reference/api/pandas.io.json.json_normalize,pandas.json_normalize
5151

52-
# api rename
52+
# rename due to refactors
53+
reference/api/pandas.core.window.Rolling,pandas.core.window.rolling.Rolling
54+
reference/api/pandas.core.window.Rolling.aggregate,pandas.core.window.rolling.Rolling.aggregate
55+
reference/api/pandas.core.window.Rolling.apply,pandas.core.window.rolling.Rolling.apply
56+
reference/api/pandas.core.window.Rolling.corr,pandas.core.window.rolling.Rolling.corr
57+
reference/api/pandas.core.window.Rolling.count,pandas.core.window.rolling.Rolling.count
58+
reference/api/pandas.core.window.Rolling.cov,pandas.core.window.rolling.Rolling.cov
59+
reference/api/pandas.core.window.Rolling.kurt,pandas.core.window.rolling.Rolling.kurt
60+
reference/api/pandas.core.window.Rolling.max,pandas.core.window.rolling.Rolling.max
61+
reference/api/pandas.core.window.Rolling.mean,pandas.core.window.rolling.Rolling.mean
62+
reference/api/pandas.core.window.Rolling.median,pandas.core.window.rolling.Rolling.median
63+
reference/api/pandas.core.window.Rolling.min,pandas.core.window.rolling.Rolling.min
64+
reference/api/pandas.core.window.Rolling.quantile,pandas.core.window.rolling.Rolling.quantile
65+
reference/api/pandas.core.window.Rolling.skew,pandas.core.window.rolling.Rolling.skew
66+
reference/api/pandas.core.window.Rolling.std,pandas.core.window.rolling.Rolling.std
67+
reference/api/pandas.core.window.Rolling.sum,pandas.core.window.rolling.Rolling.sum
68+
reference/api/pandas.core.window.Rolling.var,pandas.core.window.rolling.Rolling.var
69+
70+
# api url change (generated -> reference/api rename)
5371
api,reference/index
5472
generated/pandas.api.extensions.ExtensionArray.argsort,../reference/api/pandas.api.extensions.ExtensionArray.argsort
5573
generated/pandas.api.extensions.ExtensionArray.astype,../reference/api/pandas.api.extensions.ExtensionArray.astype
Loading

doc/source/development/contributing.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ requires a C compiler and Python environment. If you're making documentation
146146
changes, you can skip to :ref:`contributing.documentation` but you won't be able
147147
to build the documentation locally before pushing your changes.
148148

149-
Using a Docker Container
149+
Using a Docker container
150150
~~~~~~~~~~~~~~~~~~~~~~~~
151151

152152
Instead of manually setting up a development environment, you can use Docker to
@@ -754,7 +754,7 @@ You can then verify the changes look ok, then git :ref:`commit <contributing.com
754754

755755
.. _contributing.pre-commit:
756756

757-
Pre-Commit
757+
Pre-commit
758758
~~~~~~~~~~
759759

760760
You can run many of these styling checks manually as we have described above. However,
@@ -822,12 +822,12 @@ See :ref:`contributing.warnings` for more.
822822

823823
.. _contributing.type_hints:
824824

825-
Type Hints
825+
Type hints
826826
----------
827827

828828
*pandas* strongly encourages the use of :pep:`484` style type hints. New development should contain type hints and pull requests to annotate existing code are accepted as well!
829829

830-
Style Guidelines
830+
Style guidelines
831831
~~~~~~~~~~~~~~~~
832832

833833
Types imports should follow the ``from typing import ...`` convention. So rather than
@@ -903,7 +903,7 @@ The limitation here is that while a human can reasonably understand that ``is_nu
903903
904904
With custom types and inference this is not always possible so exceptions are made, but every effort should be exhausted to avoid ``cast`` before going down such paths.
905905

906-
Pandas-specific Types
906+
pandas-specific types
907907
~~~~~~~~~~~~~~~~~~~~~
908908

909909
Commonly used types specific to *pandas* will appear in `pandas._typing <https://github.com/pandas-dev/pandas/blob/master/pandas/_typing.py>`_ and you should use these where applicable. This module is private for now but ultimately this should be exposed to third party libraries who want to implement type checking against pandas.
@@ -919,7 +919,7 @@ For example, quite a few functions in *pandas* accept a ``dtype`` argument. This
919919
920920
This module will ultimately house types for repeatedly used concepts like "path-like", "array-like", "numeric", etc... and can also hold aliases for commonly appearing parameters like `axis`. Development of this module is active so be sure to refer to the source for the most up to date list of available types.
921921

922-
Validating Type Hints
922+
Validating type hints
923923
~~~~~~~~~~~~~~~~~~~~~
924924

925925
*pandas* uses `mypy <http://mypy-lang.org>`_ to statically analyze the code base and type hints. After making any change you can ensure your type hints are correct by running
@@ -1539,7 +1539,7 @@ The branch will still exist on GitHub, so to delete it there do::
15391539
.. _Gitter: https://gitter.im/pydata/pandas
15401540

15411541

1542-
Tips for a successful Pull Request
1542+
Tips for a successful pull request
15431543
==================================
15441544

15451545
If you have made it to the `Review your code`_ phase, one of the core contributors may

doc/source/whatsnew/v1.0.2.rst

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Fixed regressions
2424
- Fixed regression in :class:`DataFrame` arithmetic operations with mis-matched columns (:issue:`31623`)
2525
- Fixed regression in :meth:`GroupBy.agg` calling a user-provided function an extra time on an empty input (:issue:`31760`)
2626
- Joining on :class:`DatetimeIndex` or :class:`TimedeltaIndex` will preserve ``freq`` in simple cases (:issue:`32166`)
27+
- Fixed bug in the repr of an object-dtype ``Index`` with bools and missing values (:issue:`32146`)
2728
-
2829

2930
.. ---------------------------------------------------------------------------
@@ -85,6 +86,10 @@ Bug fixes
8586
- Fix bug in :meth:`Series.convert_dtypes` for series with mix of integers and strings (:issue:`32117`)
8687
- Fixed bug in :meth:`DataFrame.convert_dtypes`, where ``BooleanDtype`` columns were converted to ``Int64`` (:issue:`32287`)
8788

89+
**Strings**
90+
91+
- Using ``pd.NA`` with :meth:`Series.str.repeat` now correctly outputs a null value instead of raising error for vector inputs (:issue:`31632`)
92+
8893
.. ---------------------------------------------------------------------------
8994
9095
.. _whatsnew_102.contributors:

doc/source/whatsnew/v1.1.0.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Other enhancements
6767
- When writing directly to a sqlite connection :func:`to_sql` now supports the ``multi`` method (:issue:`29921`)
6868
- `OptionError` is now exposed in `pandas.errors` (:issue:`27553`)
6969
- :func:`timedelta_range` will now infer a frequency when passed ``start``, ``stop``, and ``periods`` (:issue:`32377`)
70+
- Positional slicing on a :class:`IntervalIndex` now supports slices with ``step > 1`` (:issue:`31658`)
7071
-
7172

7273
.. ---------------------------------------------------------------------------
@@ -91,6 +92,8 @@ Backwards incompatible API changes
9192
now raise a ``TypeError`` if a not-accepted keyword argument is passed into it.
9293
Previously a ``UnsupportedFunctionCall`` was raised (``AssertionError`` if ``min_count`` passed into :meth:`~DataFrameGroupby.median``) (:issue:`31485`)
9394
- :meth:`DataFrame.at` and :meth:`Series.at` will raise a ``TypeError`` instead of a ``ValueError`` if an incompatible key is passed, and ``KeyError`` if a missing key is passed, matching the behavior of ``.loc[]`` (:issue:`31722`)
95+
- Passing an integer dtype other than ``int64`` to ``np.array(period_index, dtype=...)`` will now raise ``TypeError`` instead of incorrectly using ``int64`` (:issue:`32255`)
96+
-
9497

9598
.. _whatsnew_110.api_breaking.indexing_raises_key_errors:
9699

@@ -170,7 +173,7 @@ Deprecations
170173
~~~~~~~~~~~~
171174
- Lookups on a :class:`Series` with a single-item list containing a slice (e.g. ``ser[[slice(0, 4)]]``) are deprecated, will raise in a future version. Either convert the list to tuple, or pass the slice directly instead (:issue:`31333`)
172175
- :meth:`DataFrame.mean` and :meth:`DataFrame.median` with ``numeric_only=None`` will include datetime64 and datetime64tz columns in a future version (:issue:`29941`)
173-
-
176+
- Setting values with ``.loc`` using a positional slice is deprecated and will raise in a future version. Use ``.loc`` with labels or ``.iloc`` with positions instead (:issue:`31840`)
174177
-
175178

176179
.. ---------------------------------------------------------------------------
@@ -183,7 +186,7 @@ Performance improvements
183186

184187
- Performance improvement in :class:`Timedelta` constructor (:issue:`30543`)
185188
- Performance improvement in :class:`Timestamp` constructor (:issue:`30543`)
186-
-
189+
- Performance improvement in flex arithmetic ops between :class:`DataFrame` and :class:`Series` with ``axis=0`` (:issue:`31296`)
187190
-
188191

189192
.. ---------------------------------------------------------------------------
@@ -228,7 +231,7 @@ Timezones
228231
Numeric
229232
^^^^^^^
230233
- Bug in :meth:`DataFrame.floordiv` with ``axis=0`` not treating division-by-zero like :meth:`Series.floordiv` (:issue:`31271`)
231-
-
234+
- Bug in :meth:`to_numeric` with string argument ``"uint64"`` and ``errors="coerce"`` silently fails (:issue:`32394`)
232235
-
233236

234237
Conversion
@@ -246,7 +249,6 @@ Strings
246249

247250
Interval
248251
^^^^^^^^
249-
250252
-
251253
-
252254

pandas/_libs/lib.pyx

+1-3
Original file line numberDiff line numberDiff line change
@@ -2024,8 +2024,6 @@ def maybe_convert_numeric(ndarray[object] values, set na_values,
20242024
except (TypeError, ValueError) as err:
20252025
if not seen.coerce_numeric:
20262026
raise type(err)(f"{err} at position {i}")
2027-
elif "uint64" in str(err): # Exception from check functions.
2028-
raise
20292027

20302028
seen.saw_null()
20312029
floats[i] = NaN
@@ -2298,7 +2296,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
22982296
return uints
22992297
else:
23002298
return ints
2301-
elif seen.is_bool:
2299+
elif seen.is_bool and not seen.nan_:
23022300
return bools.view(np.bool_)
23032301

23042302
return objects

pandas/_libs/ops.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def scalar_compare(object[:] values, object val, object op):
100100

101101
@cython.wraparound(False)
102102
@cython.boundscheck(False)
103-
def vec_compare(object[:] left, object[:] right, object op):
103+
def vec_compare(ndarray[object] left, ndarray[object] right, object op):
104104
"""
105105
Compare the elements of `left` with the elements of `right` pointwise,
106106
with the comparison operation described by `op`.

pandas/_libs/tslibs/timedeltas.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ class Timedelta(_Timedelta):
11671167
11681168
Possible values:
11691169
1170-
* 'Y', 'M', 'W', 'D', 'T', 'S', 'L', 'U', or 'N'
1170+
* 'W', 'D', 'T', 'S', 'L', 'U', or 'N'
11711171
* 'days' or 'day'
11721172
* 'hours', 'hour', 'hr', or 'h'
11731173
* 'minutes', 'minute', 'min', or 'm'

0 commit comments

Comments
 (0)