Skip to content

Commit 011fbaf

Browse files
committed
Merge master
2 parents add8e88 + 9c6771c commit 011fbaf

Some content is hidden

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

43 files changed

+419
-463
lines changed

.binstar.yml

-28
This file was deleted.

doc/source/user_guide/advanced.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ When working with an ``Index`` object directly, rather than via a ``DataFrame``,
573573
.. code-block:: none
574574
575575
>>> mi.levels[0].name = 'name via level'
576-
>>> mi.names[0] # only works for older panads
576+
>>> mi.names[0] # only works for older pandas
577577
'name via level'
578578
579579
As of pandas 1.0, this will *silently* fail to update the names

doc/source/user_guide/missing_data.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ the nullable :doc:`integer <integer_na>`, boolean and
791791
:ref:`dedicated string <text.types>` data types as the missing value indicator.
792792

793793
The goal of ``pd.NA`` is provide a "missing" indicator that can be used
794-
consistently accross data types (instead of ``np.nan``, ``None`` or ``pd.NaT``
794+
consistently across data types (instead of ``np.nan``, ``None`` or ``pd.NaT``
795795
depending on the data type).
796796

797797
For example, when having missing values in a Series with the nullable integer

doc/source/user_guide/text.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ l. For ``StringDtype``, :ref:`string accessor methods<api.series.str>`
101101
2. Some string methods, like :meth:`Series.str.decode` are not available
102102
on ``StringArray`` because ``StringArray`` only holds strings, not
103103
bytes.
104-
3. In comparision operations, :class:`arrays.StringArray` and ``Series`` backed
104+
3. In comparison operations, :class:`arrays.StringArray` and ``Series`` backed
105105
by a ``StringArray`` will return an object with :class:`BooleanDtype`,
106106
rather than a ``bool`` dtype object. Missing values in a ``StringArray``
107-
will propagate in comparision operations, rather than always comparing
107+
will propagate in comparison operations, rather than always comparing
108108
unequal like :attr:`numpy.nan`.
109109

110110
Everything else that follows in the rest of this document applies equally to

doc/source/whatsnew/v1.0.0.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ A new ``pd.NA`` value (singleton) is introduced to represent scalar missing
111111
values. Up to now, ``np.nan`` is used for this for float data, ``np.nan`` or
112112
``None`` for object-dtype data and ``pd.NaT`` for datetime-like data. The
113113
goal of ``pd.NA`` is provide a "missing" indicator that can be used
114-
consistently accross data types. For now, the nullable integer and boolean
114+
consistently across data types. For now, the nullable integer and boolean
115115
data types and the new string data type make use of ``pd.NA`` (:issue:`28095`).
116116

117117
.. warning::
@@ -580,8 +580,8 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
580580
- :meth:`Series.where` with ``Categorical`` dtype (or :meth:`DataFrame.where` with ``Categorical`` column) no longer allows setting new categories (:issue:`24114`)
581581
- :class:`DatetimeIndex`, :class:`TimedeltaIndex`, and :class:`PeriodIndex` constructors no longer allow ``start``, ``end``, and ``periods`` keywords, use :func:`date_range`, :func:`timedelta_range`, and :func:`period_range` instead (:issue:`23919`)
582582
- :class:`DatetimeIndex` and :class:`TimedeltaIndex` constructors no longer have a ``verify_integrity`` keyword argument (:issue:`23919`)
583-
- ``pandas.core.internals.blocks.make_block`` no longer accepts the "fastpath" keyword(:issue:`19265`)
584-
- :meth:`Block.make_block_same_class` no longer accepts the "dtype" keyword(:issue:`19434`)
583+
- ``pandas.core.internals.blocks.make_block`` no longer accepts the "fastpath" keyword (:issue:`19265`)
584+
- :meth:`Block.make_block_same_class` no longer accepts the "dtype" keyword (:issue:`19434`)
585585
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
586586
- Removed the previously deprecated :meth:`MultiIndex.to_hierarchical` (:issue:`21613`)
587587
- Removed the previously deprecated :attr:`MultiIndex.labels`, use :attr:`MultiIndex.codes` instead (:issue:`23752`)
@@ -789,7 +789,7 @@ MultiIndex
789789
^^^^^^^^^^
790790

791791
- Constructior for :class:`MultiIndex` verifies that the given ``sortorder`` is compatible with the actual ``lexsort_depth`` if ``verify_integrity`` parameter is ``True`` (the default) (:issue:`28735`)
792-
-
792+
- Series and MultiIndex `.drop` with `MultiIndex` raise exception if labels not in given in level (:issue:`8594`)
793793
-
794794

795795
I/O
@@ -826,7 +826,7 @@ Plotting
826826
- Bug where :meth:`DataFrame.boxplot` would not accept a `color` parameter like `DataFrame.plot.box` (:issue:`26214`)
827827
- Bug in the ``xticks`` argument being ignored for :meth:`DataFrame.plot.bar` (:issue:`14119`)
828828
- :func:`set_option` now validates that the plot backend provided to ``'plotting.backend'`` implements the backend when the option is set, rather than when a plot is created (:issue:`28163`)
829-
- :meth:`DataFrame.plot` now allow a ``backend`` keyword arugment to allow changing between backends in one session (:issue:`28619`).
829+
- :meth:`DataFrame.plot` now allow a ``backend`` keyword argument to allow changing between backends in one session (:issue:`28619`).
830830
- Bug in color validation incorrectly raising for non-color styles (:issue:`29122`).
831831

832832
Groupby/resample/rolling

pandas/__init__.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
try:
1111
__import__(dependency)
1212
except ImportError as e:
13-
missing_dependencies.append("{0}: {1}".format(dependency, str(e)))
13+
missing_dependencies.append(f"{dependency}: {e}")
1414

1515
if missing_dependencies:
1616
raise ImportError(
@@ -33,10 +33,10 @@
3333
# hack but overkill to use re
3434
module = str(e).replace("cannot import name ", "")
3535
raise ImportError(
36-
"C extension: {0} not built. If you want to import "
36+
f"C extension: {module} not built. If you want to import "
3737
"pandas from the source directory, you may need to run "
3838
"'python setup.py build_ext --inplace --force' to build "
39-
"the C extensions first.".format(module)
39+
"the C extensions first."
4040
)
4141

4242
from datetime import datetime
@@ -213,16 +213,16 @@ class Panel:
213213
return Panel
214214
elif name in {"SparseSeries", "SparseDataFrame"}:
215215
warnings.warn(
216-
"The {} class is removed from pandas. Accessing it from "
216+
f"The {name} class is removed from pandas. Accessing it from "
217217
"the top-level namespace will also be removed in the next "
218-
"version".format(name),
218+
"version",
219219
FutureWarning,
220220
stacklevel=2,
221221
)
222222

223223
return type(name, (), {})
224224

225-
raise AttributeError("module 'pandas' has no attribute '{}'".format(name))
225+
raise AttributeError(f"module 'pandas' has no attribute '{name}'")
226226

227227

228228
else:

pandas/_libs/intervaltree.pxi.in

-37
Original file line numberDiff line numberDiff line change
@@ -114,43 +114,6 @@ cdef class IntervalTree(IntervalMixin):
114114
sort_order = np.lexsort(values)
115115
return is_monotonic(sort_order, False)[0]
116116

117-
def get_loc(self, scalar_t key):
118-
"""Return all positions corresponding to intervals that overlap with
119-
the given scalar key
120-
"""
121-
result = Int64Vector()
122-
self.root.query(result, key)
123-
if not result.data.n:
124-
raise KeyError(key)
125-
return result.to_array().astype('intp')
126-
127-
def _get_partial_overlap(self, key_left, key_right, side):
128-
"""Return all positions corresponding to intervals with the given side
129-
falling between the left and right bounds of an interval query
130-
"""
131-
if side == 'left':
132-
values = self.left
133-
sorter = self.left_sorter
134-
else:
135-
values = self.right
136-
sorter = self.right_sorter
137-
key = [key_left, key_right]
138-
i, j = values.searchsorted(key, sorter=sorter)
139-
return sorter[i:j]
140-
141-
def get_loc_interval(self, key_left, key_right):
142-
"""Lookup the intervals enclosed in the given interval bounds
143-
144-
The given interval is presumed to have closed bounds.
145-
"""
146-
import pandas as pd
147-
left_overlap = self._get_partial_overlap(key_left, key_right, 'left')
148-
right_overlap = self._get_partial_overlap(key_left, key_right, 'right')
149-
enclosing = self.get_loc(0.5 * (key_left + key_right))
150-
combined = np.concatenate([left_overlap, right_overlap, enclosing])
151-
uniques = pd.unique(combined)
152-
return uniques.astype('intp')
153-
154117
def get_indexer(self, scalar_t[:] target):
155118
"""Return the positions corresponding to unique intervals that overlap
156119
with the given array of scalar targets.

pandas/_libs/reshape.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def unstack(reshape_t[:, :] values, uint8_t[:] mask,
2828
Py_ssize_t stride, Py_ssize_t length, Py_ssize_t width,
2929
reshape_t[:, :] new_values, uint8_t[:, :] new_mask):
3030
"""
31-
transform long sorted_values to wide new_values
31+
Transform long values to wide new_values.
3232
3333
Parameters
3434
----------

pandas/core/arrays/datetimelike.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ def _is_unique(self):
915915
__rdivmod__ = make_invalid_op("__rdivmod__")
916916

917917
def _add_datetimelike_scalar(self, other):
918-
# Overriden by TimedeltaArray
918+
# Overridden by TimedeltaArray
919919
raise TypeError(f"cannot add {type(self).__name__} and {type(other).__name__}")
920920

921921
_add_datetime_arraylike = _add_datetimelike_scalar
@@ -928,7 +928,7 @@ def _sub_datetimelike_scalar(self, other):
928928
_sub_datetime_arraylike = _sub_datetimelike_scalar
929929

930930
def _sub_period(self, other):
931-
# Overriden by PeriodArray
931+
# Overridden by PeriodArray
932932
raise TypeError(f"cannot subtract Period from a {type(self).__name__}")
933933

934934
def _add_offset(self, offset):
@@ -1085,7 +1085,7 @@ def _addsub_int_array(self, other, op):
10851085
-------
10861086
result : same class as self
10871087
"""
1088-
# _addsub_int_array is overriden by PeriodArray
1088+
# _addsub_int_array is overridden by PeriodArray
10891089
assert not is_period_dtype(self)
10901090
assert op in [operator.add, operator.sub]
10911091

pandas/core/arrays/datetimes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@ def _add_offset(self, offset):
802802
PerformanceWarning,
803803
)
804804
result = self.astype("O") + offset
805-
if len(self) == 0:
806-
# _from_sequence won't be able to infer self.tz
805+
if not len(self):
806+
# GH#30336 _from_sequence won't be able to infer self.tz
807807
return type(self)._from_sequence(result).tz_localize(self.tz)
808808

809809
return type(self)._from_sequence(result, freq="infer")

pandas/core/groupby/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class providing the base-class of operations.
44
55
The SeriesGroupBy and DataFrameGroupBy sub-class
66
(defined in pandas.core.groupby.generic)
7-
expose these user-facing objects to provide specific functionailty.
7+
expose these user-facing objects to provide specific functionality.
88
"""
99

1010
from contextlib import contextmanager

pandas/core/indexes/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ def get_indexer(
978978
right_indexer = self.right.get_indexer(target_as_index.right)
979979
indexer = np.where(left_indexer == right_indexer, left_indexer, -1)
980980
elif is_categorical(target_as_index):
981-
# get an indexer for unique categories then propogate to codes via take_1d
981+
# get an indexer for unique categories then propagate to codes via take_1d
982982
categories_indexer = self.get_indexer(target_as_index.categories)
983983
indexer = take_1d(categories_indexer, target_as_index.codes, fill_value=-1)
984984
elif not is_object_dtype(target_as_index):

pandas/core/indexes/multi.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ def drop(self, codes, level=None, errors="raise"):
20652065
dropped : MultiIndex
20662066
"""
20672067
if level is not None:
2068-
return self._drop_from_level(codes, level)
2068+
return self._drop_from_level(codes, level, errors)
20692069

20702070
if not isinstance(codes, (np.ndarray, Index)):
20712071
try:
@@ -2103,13 +2103,15 @@ def drop(self, codes, level=None, errors="raise"):
21032103

21042104
return self.delete(inds)
21052105

2106-
def _drop_from_level(self, codes, level):
2106+
def _drop_from_level(self, codes, level, errors="raise"):
21072107
codes = com.index_labels_to_array(codes)
21082108
i = self._get_level_number(level)
21092109
index = self.levels[i]
21102110
values = index.get_indexer(codes)
21112111

21122112
mask = ~algos.isin(self.codes[i], values)
2113+
if mask.all() and errors != "ignore":
2114+
raise KeyError(f"labels {codes} not found in level")
21132115

21142116
return self[mask]
21152117

pandas/core/internals/blocks.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ def quantile(self, qs, interpolation="linear", axis=0):
14491449
-------
14501450
Block
14511451
"""
1452-
# We should always have ndim == 2 becase Series dispatches to DataFrame
1452+
# We should always have ndim == 2 because Series dispatches to DataFrame
14531453
assert self.ndim == 2
14541454

14551455
values = self.get_values()
@@ -2432,7 +2432,7 @@ def fillna(self, value, **kwargs):
24322432
# Deprecation GH#24694, GH#19233
24332433
raise TypeError(
24342434
"Passing integers to fillna for timedelta64[ns] dtype is no "
2435-
"longer supporetd. To obtain the old behavior, pass "
2435+
"longer supported. To obtain the old behavior, pass "
24362436
"`pd.Timedelta(seconds=n)` instead."
24372437
)
24382438
return super().fillna(value, **kwargs)
@@ -2971,7 +2971,7 @@ def make_block(values, placement, klass=None, ndim=None, dtype=None):
29712971

29722972

29732973
def _extend_blocks(result, blocks=None):
2974-
""" return a new extended blocks, givin the result """
2974+
""" return a new extended blocks, given the result """
29752975
from pandas.core.internals import BlockManager
29762976

29772977
if blocks is None:

pandas/core/internals/managers.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -741,16 +741,17 @@ def copy(self, deep=True):
741741
742742
Parameters
743743
----------
744-
deep : boolean o rstring, default True
744+
deep : bool or string, default True
745745
If False, return shallow copy (do not copy data)
746746
If 'all', copy data and a deep copy of the index
747747
748748
Returns
749749
-------
750-
copy : BlockManager
750+
BlockManager
751751
"""
752752
# this preserves the notion of view copying of axes
753753
if deep:
754+
# hit in e.g. tests.io.json.test_pandas
754755

755756
def copy_func(ax):
756757
if deep == "all":
@@ -761,6 +762,7 @@ def copy_func(ax):
761762
new_axes = [copy_func(ax) for ax in self.axes]
762763
else:
763764
new_axes = list(self.axes)
765+
764766
res = self.apply("copy", deep=deep)
765767
res.axes = new_axes
766768
return res

pandas/core/nanops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ def f(x, y):
13371337

13381338
def _nanpercentile_1d(values, mask, q, na_value, interpolation):
13391339
"""
1340-
Wraper for np.percentile that skips missing values, specialized to
1340+
Wrapper for np.percentile that skips missing values, specialized to
13411341
1-dimensional case.
13421342
13431343
Parameters
@@ -1368,7 +1368,7 @@ def _nanpercentile_1d(values, mask, q, na_value, interpolation):
13681368

13691369
def nanpercentile(values, q, axis, na_value, mask, ndim, interpolation):
13701370
"""
1371-
Wraper for np.percentile that skips missing values.
1371+
Wrapper for np.percentile that skips missing values.
13721372
13731373
Parameters
13741374
----------

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ def __array__(self, dtype=None):
727727
Timestamp('2000-01-02 00:00:00+0100', tz='CET', freq='D')],
728728
dtype=object)
729729
730-
Or the values may be localized to UTC and the tzinfo discared with
730+
Or the values may be localized to UTC and the tzinfo discarded with
731731
``dtype='datetime64[ns]'``
732732
733733
>>> np.asarray(tzser, dtype="datetime64[ns]") # doctest: +ELLIPSIS

pandas/io/parsers.py

-2
Original file line numberDiff line numberDiff line change
@@ -2204,8 +2204,6 @@ class PythonParser(ParserBase):
22042204
def __init__(self, f, **kwds):
22052205
"""
22062206
Workhorse function for processing nested list into DataFrame
2207-
2208-
Should be replaced by np.genfromtxt eventually?
22092207
"""
22102208
ParserBase.__init__(self, kwds)
22112209

pandas/io/pytables.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@ def data_orientation(self):
32973297
def queryables(self) -> Dict[str, Any]:
32983298
""" return a dict of the kinds allowable columns for this object """
32993299

3300-
# mypy doesnt recognize DataFrame._AXIS_NAMES, so we re-write it here
3300+
# mypy doesn't recognize DataFrame._AXIS_NAMES, so we re-write it here
33013301
axis_names = {0: "index", 1: "columns"}
33023302

33033303
# compute the values_axes queryables
@@ -4993,7 +4993,7 @@ def _get_data_and_dtype_name(data: Union[np.ndarray, ABCExtensionArray]):
49934993
if data.dtype.kind in ["m", "M"]:
49944994
data = np.asarray(data.view("i8"))
49954995
# TODO: we used to reshape for the dt64tz case, but no longer
4996-
# doing that doesnt seem to break anything. why?
4996+
# doing that doesn't seem to break anything. why?
49974997

49984998
elif isinstance(data, PeriodIndex):
49994999
data = data.asi8

pandas/plotting/_matplotlib/core.py

-6
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,6 @@ def _iter_data(self, data=None, keep_index=False, fillna=None):
241241
if fillna is not None:
242242
data = data.fillna(fillna)
243243

244-
# TODO: unused?
245-
# if self.sort_columns:
246-
# columns = com.try_sort(data.columns)
247-
# else:
248-
# columns = data.columns
249-
250244
for col, values in data.items():
251245
if keep_index is True:
252246
yield col, values

0 commit comments

Comments
 (0)