Skip to content

Commit dd6be55

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into cln-misc
2 parents 9c7da9c + f1117bd commit dd6be55

Some content is hidden

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

51 files changed

+639
-757
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717

18+
- name: Setting conda path
19+
run: echo "::add-path::${HOME}/miniconda3/bin"
20+
1821
- name: Checkout
1922
uses: actions/checkout@v1
2023

21-
- name: Setting conda path
22-
run: echo "::set-env name=PATH::${HOME}/miniconda3/bin:${PATH}"
23-
2424
- name: Looking for unwanted patterns
2525
run: ci/code_checks.sh patterns
2626
if: true

ci/azure/posix.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ jobs:
4444
PATTERN: "not slow and not network"
4545
LOCALE_OVERRIDE: "zh_CN.UTF-8"
4646

47-
py37_np_dev:
48-
ENV_FILE: ci/deps/azure-37-numpydev.yaml
49-
CONDA_PY: "37"
50-
PATTERN: "not slow and not network"
51-
TEST_ARGS: "-W error"
52-
PANDAS_TESTING_MODE: "deprecate"
53-
EXTRA_APT: "xsel"
47+
# Disabled for NumPy object-dtype warning.
48+
# https://github.com/pandas-dev/pandas/issues/30043
49+
# py37_np_dev:
50+
# ENV_FILE: ci/deps/azure-37-numpydev.yaml
51+
# CONDA_PY: "37"
52+
# PATTERN: "not slow and not network"
53+
# TEST_ARGS: "-W error"
54+
# PANDAS_TESTING_MODE: "deprecate"
55+
# EXTRA_APT: "xsel"
5456

5557
steps:
5658
- script: |

ci/deps/azure-36-locale.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ dependencies:
2727
- xlrd=1.1.0
2828
- xlsxwriter=0.9.8
2929
- xlwt=1.2.0
30+
# lowest supported version of pyarrow (putting it here instead of in
31+
# azure-36-minimum_versions because it needs numpy >= 1.14)
32+
- pyarrow=0.12
3033
- pip
3134
- pip:
3235
- html5lib==1.0b2

ci/deps/azure-37-locale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: pandas-dev
22
channels:
3-
- defaults
43
- conda-forge
54
dependencies:
65
- python=3.7.*
@@ -33,3 +32,4 @@ dependencies:
3332
- xlrd
3433
- xlsxwriter
3534
- xlwt
35+
- pyarrow>=0.15

ci/deps/travis-36-cov.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ dependencies:
2727
- numexpr
2828
- numpy=1.15.*
2929
- odfpy
30-
- openpyxl
30+
- openpyxl<=3.0.1
31+
# https://github.com/pandas-dev/pandas/pull/30009 openpyxl 3.0.2 broke
3132
- pandas-gbq
3233
# https://github.com/pydata/pandas-gbq/issues/271
3334
- google-cloud-bigquery<=1.11
3435
- psycopg2
35-
# pyarrow segfaults on load: https://github.com/pandas-dev/pandas/issues/26716
36-
# - pyarrow=0.9.0
36+
- pyarrow>=0.12.0
3737
- pymysql
3838
- pytables
3939
- python-snappy

ci/print_skipped.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
def main(filename):
77
if not os.path.isfile(filename):
8-
return
8+
raise RuntimeError(f"Could not find junit file {filename!r}")
99

1010
tree = et.parse(filename)
1111
root = tree.getroot()
1212
current_class = ""
13-
for el in root.findall("testcase"):
13+
for el in root.iter("testcase"):
1414
cn = el.attrib["classname"]
1515
for sk in el.findall("skipped"):
1616
old_class = current_class
@@ -32,8 +32,7 @@ def main(filename):
3232
print("-" * 80)
3333
else:
3434
print(
35-
"#{i} {class_name}.{test_name}: {message}".format(
36-
**dict(test_data, i=i)
37-
)
35+
f"#{i} {test_data['class_name']}."
36+
f"{test_data['test_name']}: {test_data['message']}"
3837
)
3938
i += 1

doc/redirects.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ generated/pandas.Index.equals,../reference/api/pandas.Index.equals
636636
generated/pandas.Index.factorize,../reference/api/pandas.Index.factorize
637637
generated/pandas.Index.fillna,../reference/api/pandas.Index.fillna
638638
generated/pandas.Index.format,../reference/api/pandas.Index.format
639-
generated/pandas.Index.get_duplicates,../reference/api/pandas.Index.get_duplicates
640639
generated/pandas.Index.get_indexer_for,../reference/api/pandas.Index.get_indexer_for
641640
generated/pandas.Index.get_indexer,../reference/api/pandas.Index.get_indexer
642641
generated/pandas.Index.get_indexer_non_unique,../reference/api/pandas.Index.get_indexer_non_unique
@@ -1120,7 +1119,6 @@ generated/pandas.Series.pow,../reference/api/pandas.Series.pow
11201119
generated/pandas.Series.prod,../reference/api/pandas.Series.prod
11211120
generated/pandas.Series.product,../reference/api/pandas.Series.product
11221121
generated/pandas.Series.ptp,../reference/api/pandas.Series.ptp
1123-
generated/pandas.Series.put,../reference/api/pandas.Series.put
11241122
generated/pandas.Series.quantile,../reference/api/pandas.Series.quantile
11251123
generated/pandas.Series.radd,../reference/api/pandas.Series.radd
11261124
generated/pandas.Series.rank,../reference/api/pandas.Series.rank

doc/source/reference/indexing.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ Selecting
152152
Index.asof
153153
Index.asof_locs
154154
Index.contains
155-
Index.get_duplicates
156155
Index.get_indexer
157156
Index.get_indexer_for
158157
Index.get_indexer_non_unique

doc/source/reference/series.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Attributes
3939
Series.empty
4040
Series.dtypes
4141
Series.name
42-
Series.put
4342

4443
Conversion
4544
----------

doc/source/whatsnew/v1.0.0.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
506506
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)
507507
- Changed the the default value of `inplace` in :meth:`DataFrame.set_index` and :meth:`Series.set_axis`. It now defaults to ``False`` (:issue:`27600`)
508508
- Removed the previously deprecated :attr:`Series.cat.categorical`, :attr:`Series.cat.index`, :attr:`Series.cat.name` (:issue:`24751`)
509+
- Removed the previously deprecated ``time_rule`` keyword from (non-public) :func:`offsets.generate_range`, which has been moved to :func:`core.arrays._ranges.generate_range` (:issue:`24157`)
510+
- :meth:`DataFrame.loc` or :meth:`Series.loc` with listlike indexers and missing labels will no longer reindex (:issue:`17295`)
511+
- :meth:`DataFrame.to_excel` and :meth:`Series.to_excel` with non-existent columns will no longer reindex (:issue:`17295`)
509512
- Removed the previously deprecated "by" keyword from :meth:`DataFrame.sort_index`, use :meth:`DataFrame.sort_values` instead (:issue:`10726`)
510513
- Removed support for nested renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`18529`)
511514
- Passing ``datetime64`` data to :class:`TimedeltaIndex` or ``timedelta64`` data to ``DatetimeIndex`` now raises ``TypeError`` (:issue:`23539`, :issue:`23937`)
@@ -548,7 +551,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
548551
- Removed the previously properties :attr:`DataFrame.is_copy`, :attr:`Series.is_copy` (:issue:`18812`)
549552
- Removed the previously deprecated :meth:`DataFrame.get_ftype_counts`, :meth:`Series.get_ftype_counts` (:issue:`18243`)
550553
- Removed the previously deprecated :meth:`DataFrame.ftypes`, :meth:`Series.ftypes`, :meth:`Series.ftype` (:issue:`26744`)
551-
- Removed the previously deprecated :meth:`Index.get_duplicated`, use ``idx[idx.duplicated()].unique()`` instead (:issue:`20239`)
554+
- Removed the previously deprecated :meth:`Index.get_duplicates`, use ``idx[idx.duplicated()].unique()`` instead (:issue:`20239`)
552555
- Removed the previously deprecated :meth:`Series.clip_upper`, :meth:`Series.clip_lower`, :meth:`DataFrame.clip_upper`, :meth:`DataFrame.clip_lower` (:issue:`24203`)
553556
- Removed the ability to alter :attr:`DatetimeIndex.freq`, :attr:`TimedeltaIndex.freq`, or :attr:`PeriodIndex.freq` (:issue:`20772`)
554557
- Removed the previously deprecated :attr:`DatetimeIndex.offset` (:issue:`20730`)
@@ -562,6 +565,9 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
562565
- Passing multiple axes to :meth:`DataFrame.dropna` is no longer supported (:issue:`20995`)
563566
- Removed previously deprecated :meth:`Series.nonzero`, use `to_numpy().nonzero()` instead (:issue:`24048`)
564567
- Passing floating dtype ``codes`` to :meth:`Categorical.from_codes` is no longer supported, pass ``codes.astype(np.int64)`` instead (:issue:`21775`)
568+
- :meth:`Series.str.partition` and :meth:`Series.str.rpartition` no longer accept "pat" keyword, use "sep" instead (:issue:`23767`)
569+
- Removed the previously deprecated :meth:`Series.put` (:issue:`27106`)
570+
- Removed the previously deprecated :attr:`Series.real`, :attr:`Series.imag` (:issue:`27106`)
565571
- Removed the previously deprecated :meth:`Series.to_dense`, :meth:`DataFrame.to_dense` (:issue:`26684`)
566572
- Removed the previously deprecated :meth:`Index.dtype_str`, use ``str(index.dtype)`` instead (:issue:`27106`)
567573
- :meth:`Categorical.ravel` returns a :class:`Categorical` instead of a ``ndarray`` (:issue:`27199`)
@@ -658,6 +664,7 @@ Numeric
658664
- Bug in :class:`UInt64Index` precision loss while constructing from a list with values in the ``np.uint64`` range (:issue:`29526`)
659665
- Bug in :class:`NumericIndex` construction that caused indexing to fail when integers in the ``np.uint64`` range were used (:issue:`28023`)
660666
- Bug in :class:`NumericIndex` construction that caused :class:`UInt64Index` to be casted to :class:`Float64Index` when integers in the ``np.uint64`` range were used to index a :class:`DataFrame` (:issue:`28279`)
667+
- Bug in :meth:`Series.interpolate` when using method=`index` with an unsorted index, would previously return incorrect results. (:issue:`21037`)
661668

662669
Conversion
663670
^^^^^^^^^^

doc/sphinxext/announce.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ def build_string(revision_range, heading="Contributors"):
113113
components["authors"] = "* " + "\n* ".join(components["authors"])
114114

115115
tpl = textwrap.dedent(
116-
"""\
117-
{heading}
118-
{uline}
116+
f"""\
117+
{components['heading']}
118+
{components['uline']}
119119
120-
{author_message}
121-
{authors}"""
122-
).format(**components)
120+
{components['author_message']}
121+
{components['authors']}"""
122+
)
123123
return tpl
124124

125125

doc/sphinxext/contributors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def run(self):
2727
except git.GitCommandError as exc:
2828
return [
2929
self.state.document.reporter.warning(
30-
"Cannot find contributors for range '{}': {}".format(range_, exc),
30+
f"Cannot find contributors for range {repr(range_)}: {exc}",
3131
line=self.lineno,
3232
)
3333
]

pandas/_libs/parsers.pyx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ from pandas.errors import (ParserError, DtypeWarning,
6363

6464
lzma = _import_lzma()
6565

66-
# Import CParserError as alias of ParserError for backwards compatibility.
67-
# Ultimately, we want to remove this import. See gh-12665 and gh-14479.
68-
CParserError = ParserError
69-
70-
7166
cdef:
7267
float64_t INF = <float64_t>np.inf
7368
float64_t NEGINF = -INF

pandas/compat/chainmap.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ def __setitem__(self, key, value):
1010
self.maps[0][key] = value
1111

1212
def __delitem__(self, key):
13+
"""
14+
Raises
15+
------
16+
KeyError
17+
If `key` doesn't exist.
18+
"""
1319
for mapping in self.maps:
1420
if key in mapping:
1521
del mapping[key]

pandas/core/arrays/numpy_.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numbers
2+
from typing import Union
23

34
import numpy as np
45
from numpy.lib.mixins import NDArrayOperatorsMixin
@@ -117,11 +118,12 @@ class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin):
117118
# pandas internals, which turns off things like block consolidation.
118119
_typ = "npy_extension"
119120
__array_priority__ = 1000
121+
_ndarray: np.ndarray
120122

121123
# ------------------------------------------------------------------------
122124
# Constructors
123125

124-
def __init__(self, values, copy=False):
126+
def __init__(self, values: Union[np.ndarray, "PandasArray"], copy: bool = False):
125127
if isinstance(values, type(self)):
126128
values = values._ndarray
127129
if not isinstance(values, np.ndarray):

pandas/core/base.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ def __setattr__(self, key, value):
114114
or key in type(self).__dict__
115115
or getattr(self, key, None) is not None
116116
):
117-
raise AttributeError(
118-
"You cannot add any new attribute '{key}'".format(key=key)
119-
)
117+
raise AttributeError(f"You cannot add any new attribute '{key}'")
120118
object.__setattr__(self, key, value)
121119

122120

@@ -220,28 +218,22 @@ def _obj_with_exclusions(self):
220218

221219
def __getitem__(self, key):
222220
if self._selection is not None:
223-
raise IndexError(
224-
"Column(s) {selection} already selected".format(
225-
selection=self._selection
226-
)
227-
)
221+
raise IndexError(f"Column(s) {self._selection} already selected")
228222

229223
if isinstance(key, (list, tuple, ABCSeries, ABCIndexClass, np.ndarray)):
230224
if len(self.obj.columns.intersection(key)) != len(key):
231225
bad_keys = list(set(key).difference(self.obj.columns))
232-
raise KeyError(
233-
"Columns not found: {missing}".format(missing=str(bad_keys)[1:-1])
234-
)
226+
raise KeyError(f"Columns not found: {str(bad_keys)[1:-1]}")
235227
return self._gotitem(list(key), ndim=2)
236228

237229
elif not getattr(self, "as_index", False):
238230
if key not in self.obj.columns:
239-
raise KeyError("Column not found: {key}".format(key=key))
231+
raise KeyError(f"Column not found: {key}")
240232
return self._gotitem(key, ndim=2)
241233

242234
else:
243235
if key not in self.obj:
244-
raise KeyError("Column not found: {key}".format(key=key))
236+
raise KeyError(f"Column not found: {key}")
245237
return self._gotitem(key, ndim=1)
246238

247239
def _gotitem(self, key, ndim, subset=None):
@@ -293,8 +285,7 @@ def _try_aggregate_string_function(self, arg: str, *args, **kwargs):
293285
return f(self, *args, **kwargs)
294286

295287
raise AttributeError(
296-
"'{arg}' is not a valid function for "
297-
"'{cls}' object".format(arg=arg, cls=type(self).__name__)
288+
f"'{arg}' is not a valid function for '{type(self).__name__}' object"
298289
)
299290

300291
def _aggregate(self, arg, *args, **kwargs):
@@ -359,7 +350,7 @@ def _aggregate(self, arg, *args, **kwargs):
359350
elif isinstance(obj, ABCSeries):
360351
raise SpecificationError("nested renamer is not supported")
361352
elif isinstance(obj, ABCDataFrame) and k not in obj.columns:
362-
raise KeyError("Column '{col}' does not exist!".format(col=k))
353+
raise KeyError(f"Column '{k}' does not exist!")
363354

364355
arg = new_arg
365356

@@ -1101,9 +1092,7 @@ def _reduce(
11011092
func = getattr(self, name, None)
11021093
if func is None:
11031094
raise TypeError(
1104-
"{klass} cannot perform the operation {op}".format(
1105-
klass=type(self).__name__, op=name
1106-
)
1095+
f"{type(self).__name__} cannot perform the operation {name}"
11071096
)
11081097
return func(skipna=skipna, **kwds)
11091098

0 commit comments

Comments
 (0)