Skip to content

Commit 6d4bb3f

Browse files
committed
Merge branch 'master' into forward-indexer
2 parents 4314cbe + 37dc5dc commit 6d4bb3f

Some content is hidden

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

49 files changed

+434
-344
lines changed

ci/code_checks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
327327
RET=$(($RET + $?)) ; echo $MSG "DONE"
328328

329329
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
330+
$BASE_DIR/scripts/validate_rst_title_capitalization.py $BASE_DIR/doc/source/development/contributing.rst $BASE_DIR/doc/source/reference
331331
RET=$(($RET + $?)) ; echo $MSG "DONE"
332332

333333
fi

doc/source/development/code_style.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ consistent code format throughout the project. For details see the
1818
Patterns
1919
========
2020

21-
foo.__class__
22-
-------------
21+
Using foo.__class__
22+
-------------------
2323

2424

2525
pandas uses 'type(foo)' instead 'foo.__class__' as it is making the code more
@@ -47,8 +47,8 @@ String formatting
4747
Concatenated strings
4848
--------------------
4949

50-
f-strings
51-
~~~~~~~~~
50+
Using f-strings
51+
~~~~~~~~~~~~~~~
5252

5353
pandas uses f-strings formatting instead of '%' and '.format()' string formatters.
5454

doc/source/development/contributing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ Below is a brief overview on how to set-up a virtual environment with Powershell
295295
under Windows. For details please refer to the
296296
`official virtualenv user guide <https://virtualenv.pypa.io/en/stable/userguide/#activate-script>`__
297297

298-
Use an ENV_DIR of your choice. We'll use ~\virtualenvs\pandas-dev where
298+
Use an ENV_DIR of your choice. We'll use ~\\virtualenvs\\pandas-dev where
299299
'~' is the folder pointed to by either $env:USERPROFILE (Powershell) or
300300
%USERPROFILE% (cmd.exe) environment variable. Any parent directories
301301
should already exist.

doc/source/development/extending.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ and comments contain guidance for properly implementing the interface.
139139

140140
.. _extending.extension.operator:
141141

142-
:class:`~pandas.api.extensions.ExtensionArray` Operator Support
142+
:class:`~pandas.api.extensions.ExtensionArray` operator support
143143
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144144

145145
.. versionadded:: 0.24.0

doc/source/development/policies.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Policies
66

77
.. _policies.version:
88

9-
Version Policy
9+
Version policy
1010
~~~~~~~~~~~~~~
1111

1212
.. versionchanged:: 1.0.0
@@ -48,7 +48,7 @@ deprecation removed in the next next major release (2.0.0).
4848
These policies do not apply to features marked as **experimental** in the documentation.
4949
pandas may change the behavior of experimental features at any time.
5050

51-
Python Support
51+
Python support
5252
~~~~~~~~~~~~~~
5353

5454
pandas will only drop support for specific Python versions (e.g. 3.6.x, 3.7.x) in

doc/source/development/roadmap.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ We'd like to fund improvements and maintenance of these tools to
152152

153153
.. _roadmap.evolution:
154154

155-
Roadmap Evolution
155+
Roadmap evolution
156156
-----------------
157157

158158
pandas continues to evolve. The direction is primarily determined by community

doc/source/getting_started/intro_tutorials/09_timeseries.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ objects. In pandas we call these datetime objects similar to
9696

9797
pd.read_csv("../data/air_quality_no2_long.csv", parse_dates=["datetime"])
9898

99-
Why are these :class:`pandas.Timestamp` objects useful. Let’s illustrate the added
99+
Why are these :class:`pandas.Timestamp` objects useful? Let’s illustrate the added
100100
value with some example cases.
101101

102102
What is the start and end date of the time series data set working
@@ -106,7 +106,7 @@ value with some example cases.
106106
107107
air_quality["datetime"].min(), air_quality["datetime"].max()
108108
109-
Using :class:`pandas.Timestamp` for datetimes enable us to calculate with date
109+
Using :class:`pandas.Timestamp` for datetimes enables us to calculate with date
110110
information and make them comparable. Hence, we can use this to get the
111111
length of our time series:
112112

@@ -122,7 +122,7 @@ from the standard Python library and defining a time duration.
122122
<div class="d-flex flex-row gs-torefguide">
123123
<span class="badge badge-info">To user guide</span>
124124

125-
The different time concepts supported by pandas are explained in the user guide section on :ref:`time related concepts <timeseries.overview>`.
125+
The various time concepts supported by pandas are explained in the user guide section on :ref:`time related concepts <timeseries.overview>`.
126126

127127
.. raw:: html
128128

@@ -157,7 +157,7 @@ accessible by the ``dt`` accessor.
157157

158158
An overview of the existing date properties is given in the
159159
:ref:`time and date components overview table <timeseries.components>`. More details about the ``dt`` accessor
160-
to return datetime like properties is explained in a dedicated section on the :ref:`dt accessor <basics.dt_accessors>`.
160+
to return datetime like properties are explained in a dedicated section on the :ref:`dt accessor <basics.dt_accessors>`.
161161

162162
.. raw:: html
163163

@@ -353,7 +353,7 @@ Make a plot of the daily mean :math:`NO_2` value in each of the stations.
353353
<div class="d-flex flex-row gs-torefguide">
354354
<span class="badge badge-info">To user guide</span>
355355

356-
More details on the power of time series ``resampling`` is provided in the user gudie section on :ref:`resampling <timeseries.resampling>`.
356+
More details on the power of time series ``resampling`` is provided in the user guide section on :ref:`resampling <timeseries.resampling>`.
357357

358358
.. raw:: html
359359

@@ -366,7 +366,7 @@ More details on the power of time series ``resampling`` is provided in the user
366366

367367
- Valid date strings can be converted to datetime objects using
368368
``to_datetime`` function or as part of read functions.
369-
- Datetime objects in pandas supports calculations, logical operations
369+
- Datetime objects in pandas support calculations, logical operations
370370
and convenient date-related properties using the ``dt`` accessor.
371371
- A ``DatetimeIndex`` contains these date-related properties and
372372
supports convenient slicing.
@@ -382,7 +382,7 @@ More details on the power of time series ``resampling`` is provided in the user
382382
<div class="d-flex flex-row gs-torefguide">
383383
<span class="badge badge-info">To user guide</span>
384384

385-
A full overview on time series is given in the pages on :ref:`time series and date functionality <timeseries>`.
385+
A full overview on time series is given on the pages on :ref:`time series and date functionality <timeseries>`.
386386

387387
.. raw:: html
388388

doc/source/reference/frame.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Combining / joining / merging
251251
DataFrame.merge
252252
DataFrame.update
253253

254-
Time series-related
254+
Time Series-related
255255
~~~~~~~~~~~~~~~~~~~
256256
.. autosummary::
257257
:toctree: api/

doc/source/reference/indexing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ DatetimeIndex
328328

329329
DatetimeIndex
330330

331-
Time/Date components
331+
Time/date components
332332
~~~~~~~~~~~~~~~~~~~~
333333
.. autosummary::
334334
:toctree: api/

doc/source/reference/series.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Binary operator functions
110110
Series.product
111111
Series.dot
112112

113-
Function application, groupby & window
113+
Function application, GroupBy & window
114114
--------------------------------------
115115
.. autosummary::
116116
:toctree: api/
@@ -249,7 +249,7 @@ Combining / joining / merging
249249
Series.replace
250250
Series.update
251251

252-
Time series-related
252+
Time Series-related
253253
-------------------
254254
.. autosummary::
255255
:toctree: api/

doc/source/whatsnew/v1.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Other enhancements
8787
- Positional slicing on a :class:`IntervalIndex` now supports slices with ``step > 1`` (:issue:`31658`)
8888
- :class:`Series.str` now has a `fullmatch` method that matches a regular expression against the entire string in each row of the series, similar to `re.fullmatch` (:issue:`32806`).
8989
- :meth:`DataFrame.sample` will now also allow array-like and BitGenerator objects to be passed to ``random_state`` as seeds (:issue:`32503`)
90+
- :meth:`MultiIndex.union` will now raise `RuntimeWarning` if the object inside are unsortable, pass `sort=False` to suppress this warning (:issue:`33015`)
9091
-
9192

9293
.. ---------------------------------------------------------------------------

pandas/_libs/lib.pyx

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from fractions import Fraction
44
from numbers import Number
55

66
import sys
7+
import warnings
78

89
import cython
910
from cython import Py_ssize_t
@@ -286,7 +287,11 @@ def fast_unique_multiple(list arrays, sort: bool = True):
286287
try:
287288
uniques.sort()
288289
except TypeError:
289-
# TODO: RuntimeWarning?
290+
warnings.warn(
291+
"The values in the array are unorderable. "
292+
"Pass `sort=False` to suppress this warning.",
293+
RuntimeWarning,
294+
)
290295
pass
291296

292297
return uniques

pandas/_libs/tslibs/conversion.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ from pandas._libs.tslibs.tzconversion cimport (
4444
# ----------------------------------------------------------------------
4545
# Constants
4646

47-
NS_DTYPE = np.dtype('M8[ns]')
48-
TD_DTYPE = np.dtype('m8[ns]')
47+
DT64NS_DTYPE = np.dtype('M8[ns]')
48+
TD64NS_DTYPE = np.dtype('m8[ns]')
4949

5050

5151
# ----------------------------------------------------------------------
@@ -105,11 +105,11 @@ def ensure_datetime64ns(arr: ndarray, copy: bool=True):
105105

106106
ivalues = arr.view(np.int64).ravel()
107107

108-
result = np.empty(shape, dtype=NS_DTYPE)
108+
result = np.empty(shape, dtype=DT64NS_DTYPE)
109109
iresult = result.ravel().view(np.int64)
110110

111111
if len(iresult) == 0:
112-
result = arr.view(NS_DTYPE)
112+
result = arr.view(DT64NS_DTYPE)
113113
if copy:
114114
result = result.copy()
115115
return result
@@ -145,7 +145,7 @@ def ensure_timedelta64ns(arr: ndarray, copy: bool=True):
145145
result : ndarray with dtype timedelta64[ns]
146146
147147
"""
148-
return arr.astype(TD_DTYPE, copy=copy)
148+
return arr.astype(TD64NS_DTYPE, copy=copy)
149149
# TODO: check for overflows when going from a lower-resolution to nanos
150150

151151

pandas/_libs/writers.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def convert_json_to_lines(arr: object) -> str:
112112
if not in_quotes:
113113
num_open_brackets_seen -= 1
114114

115-
return narr.tostring().decode('utf-8')
115+
return narr.tobytes().decode('utf-8')
116116

117117

118118
# stata, pytables

pandas/core/arrays/categorical.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def __init__(
378378
old_codes = (
379379
values._values.codes if isinstance(values, ABCSeries) else values.codes
380380
)
381-
codes = _recode_for_categories(
381+
codes = recode_for_categories(
382382
old_codes, values.dtype.categories, dtype.categories
383383
)
384384

@@ -572,13 +572,13 @@ def _from_inferred_categories(
572572
if known_categories:
573573
# Recode from observation order to dtype.categories order.
574574
categories = dtype.categories
575-
codes = _recode_for_categories(inferred_codes, cats, categories)
575+
codes = recode_for_categories(inferred_codes, cats, categories)
576576
elif not cats.is_monotonic_increasing:
577577
# Sort categories and recode for unknown categories.
578578
unsorted = cats.copy()
579579
categories = cats.sort_values()
580580

581-
codes = _recode_for_categories(inferred_codes, unsorted, categories)
581+
codes = recode_for_categories(inferred_codes, unsorted, categories)
582582
dtype = CategoricalDtype(categories, ordered=False)
583583
else:
584584
dtype = CategoricalDtype(cats, ordered=False)
@@ -727,7 +727,7 @@ def _set_dtype(self, dtype: CategoricalDtype) -> "Categorical":
727727
We don't do any validation here. It's assumed that the dtype is
728728
a (valid) instance of `CategoricalDtype`.
729729
"""
730-
codes = _recode_for_categories(self.codes, self.categories, dtype.categories)
730+
codes = recode_for_categories(self.codes, self.categories, dtype.categories)
731731
return type(self)(codes, dtype=dtype, fastpath=True)
732732

733733
def set_ordered(self, value, inplace=False):
@@ -849,7 +849,7 @@ def set_categories(self, new_categories, ordered=None, rename=False, inplace=Fal
849849
# remove all _codes which are larger and set to -1/NaN
850850
cat._codes[cat._codes >= len(new_dtype.categories)] = -1
851851
else:
852-
codes = _recode_for_categories(
852+
codes = recode_for_categories(
853853
cat.codes, cat.categories, new_dtype.categories
854854
)
855855
cat._codes = codes
@@ -2034,7 +2034,7 @@ def __setitem__(self, key, value):
20342034
"without identical categories"
20352035
)
20362036
if not self.categories.equals(value.categories):
2037-
new_codes = _recode_for_categories(
2037+
new_codes = recode_for_categories(
20382038
value.codes, value.categories, self.categories
20392039
)
20402040
value = Categorical.from_codes(new_codes, dtype=self.dtype)
@@ -2298,7 +2298,7 @@ def equals(self, other):
22982298
# fastpath to avoid re-coding
22992299
other_codes = other._codes
23002300
else:
2301-
other_codes = _recode_for_categories(
2301+
other_codes = recode_for_categories(
23022302
other.codes, other.categories, self.categories
23032303
)
23042304
return np.array_equal(self._codes, other_codes)
@@ -2667,7 +2667,7 @@ def _get_codes_for_values(values, categories):
26672667
return coerce_indexer_dtype(t.lookup(vals), cats)
26682668

26692669

2670-
def _recode_for_categories(codes: np.ndarray, old_categories, new_categories):
2670+
def recode_for_categories(codes: np.ndarray, old_categories, new_categories):
26712671
"""
26722672
Convert a set of codes for to a new set of categories
26732673
@@ -2685,7 +2685,7 @@ def _recode_for_categories(codes: np.ndarray, old_categories, new_categories):
26852685
>>> old_cat = pd.Index(['b', 'a', 'c'])
26862686
>>> new_cat = pd.Index(['a', 'b'])
26872687
>>> codes = np.array([0, 1, 1, 2])
2688-
>>> _recode_for_categories(codes, old_cat, new_cat)
2688+
>>> recode_for_categories(codes, old_cat, new_cat)
26892689
array([ 1, 0, 0, -1], dtype=int8)
26902690
"""
26912691
if len(old_categories) == 0:

0 commit comments

Comments
 (0)