Skip to content

Commit f6595be

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 8b6942f + 35821a5 commit f6595be

39 files changed

+220
-97
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
custom: https://pandas.pydata.org/donate.html
2+
tidelift: pypi/pandas

.github/SECURITY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
To report a security vulnerability to pandas, please go to https://tidelift.com/security and see the instructions there.

ci/deps/azure-37-locale.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
- openpyxl
1818
- pytables
1919
- python-dateutil
20-
- python=3.7.*
20+
- python=3.7.3
2121
- pytz
2222
- s3fs
2323
- scipy
@@ -26,8 +26,8 @@ dependencies:
2626
- xlsxwriter
2727
- xlwt
2828
# universal
29-
- pytest>=4.0.2
30-
- pytest-xdist
29+
- pytest>=5.0.1
30+
- pytest-xdist>=1.29.0
3131
- pytest-mock
3232
- pytest-azurepipelines
3333
- pip

ci/deps/azure-37-numpydev.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ name: pandas-dev
22
channels:
33
- defaults
44
dependencies:
5-
- python=3.7.*
5+
- python=3.7.3
66
- pytz
77
- Cython>=0.28.2
88
# universal
9-
- pytest>=4.0.2
9+
# pytest < 5 until defaults has pytest-xdist>=1.29.0
10+
- pytest>=4.0.2,<5.0
1011
- pytest-xdist
1112
- pytest-mock
1213
- hypothesis>=3.58.0

ci/deps/azure-macos-35.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ dependencies:
2525
- pip:
2626
- pyreadstat
2727
# universal
28-
- pytest==4.5.0
29-
- pytest-xdist
28+
- pytest>=5.0.1
29+
- pytest-xdist>=1.29.0
3030
- pytest-mock
3131
- hypothesis>=3.58.0
3232
# https://github.com/pandas-dev/pandas/issues/27421

ci/deps/azure-windows-36.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ dependencies:
2323
- xlwt
2424
# universal
2525
- cython>=0.28.2
26-
- pytest>=4.0.2
27-
- pytest-xdist
26+
- pytest>=5.0.1
27+
- pytest-xdist>=1.29.0
2828
- pytest-mock
2929
- pytest-azurepipelines
3030
- hypothesis>=3.58.0

ci/deps/azure-windows-37.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ dependencies:
2626
- xlwt
2727
# universal
2828
- cython>=0.28.2
29-
- pytest>=4.0.2
30-
- pytest-xdist
29+
- pytest>=5.0.0
30+
- pytest-xdist>=1.29.0
3131
- pytest-mock
3232
- pytest-azurepipelines
3333
- hypothesis>=3.58.0

ci/deps/travis-36-cov.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ dependencies:
3939
- xlsxwriter
4040
- xlwt
4141
# universal
42-
- pytest
43-
- pytest-xdist
42+
- pytest>=5.0.1
43+
- pytest-xdist>=1.29.0
4444
- pytest-cov
4545
- pytest-mock
4646
- hypothesis>=3.58.0

ci/deps/travis-37.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ channels:
44
- conda-forge
55
- c3i_test
66
dependencies:
7-
- python=3.7.*
7+
- python=3.7.3
88
- botocore>=1.11
99
- cython>=0.28.2
1010
- numpy
@@ -13,8 +13,8 @@ dependencies:
1313
- pyarrow
1414
- pytz
1515
# universal
16-
- pytest>=4.0.2
17-
- pytest-xdist
16+
- pytest>=5.0.0
17+
- pytest-xdist>=1.29.0
1818
- pytest-mock
1919
- hypothesis>=3.58.0
2020
- s3fs

doc/source/reference/extensions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ objects.
4444
api.extensions.ExtensionArray.argsort
4545
api.extensions.ExtensionArray.astype
4646
api.extensions.ExtensionArray.copy
47+
api.extensions.ExtensionArray.view
4748
api.extensions.ExtensionArray.dropna
4849
api.extensions.ExtensionArray.factorize
4950
api.extensions.ExtensionArray.fillna

doc/source/whatsnew/v0.25.1.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,23 @@ MultiIndex
104104
I/O
105105
^^^
106106

107-
-
107+
- Avoid calling ``S3File.s3`` when reading parquet, as this was removed in s3fs version 0.3.0 (:issue:`27756`)
108108
-
109109
-
110110

111111
Plotting
112112
^^^^^^^^
113113

114114
- Added a pandas_plotting_backends entrypoint group for registering plot backends. See :ref:`extending.plotting-backends` for more (:issue:`26747`).
115-
-
115+
- Fix compatibility issue with matplotlib when passing a pandas ``Index`` to a plot call (:issue:`27775`).
116116
-
117117

118118
Groupby/resample/rolling
119119
^^^^^^^^^^^^^^^^^^^^^^^^
120120

121121
- Bug in :meth:`pandas.core.groupby.DataFrameGroupBy.transform` where applying a timezone conversion lambda function would drop timezone information (:issue:`27496`)
122122
- Bug in windowing over read-only arrays (:issue:`27766`)
123-
-
123+
- Fixed segfault in `pandas.core.groupby.DataFrameGroupBy.quantile` when an invalid quantile was passed (:issue:`27470`)
124124
-
125125

126126
Reshaping

doc/source/whatsnew/v1.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ I/O
163163
Plotting
164164
^^^^^^^^
165165

166-
-
166+
- Bug in :meth:`Series.plot` not able to plot boolean values (:issue:`23719`)
167167
-
168168

169169
Groupby/resample/rolling

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ channels:
55
dependencies:
66
# required
77
- numpy>=1.15
8-
- python=3
8+
- python=3.7.3
99
- python-dateutil>=2.6.1
1010
- pytz
1111

pandas/_libs/groupby.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,11 @@ def group_quantile(ndarray[float64_t] out,
719719
ndarray[int64_t] counts, non_na_counts, sort_arr
720720

721721
assert values.shape[0] == N
722+
723+
if not (0 <= q <= 1):
724+
raise ValueError("'q' must be between 0 and 1. Got"
725+
" '{}' instead".format(q))
726+
722727
inter_methods = {
723728
'linear': INTERPOLATION_LINEAR,
724729
'lower': INTERPOLATION_LOWER,

pandas/core/arrays/base.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class ExtensionArray:
6464
shift
6565
take
6666
unique
67+
view
6768
_concat_same_type
6869
_formatter
6970
_from_factorized
@@ -146,7 +147,7 @@ class ExtensionArray:
146147
If implementing NumPy's ``__array_ufunc__`` interface, pandas expects
147148
that
148149
149-
1. You defer by raising ``NotImplemented`` when any Series are present
150+
1. You defer by returning ``NotImplemented`` when any Series are present
150151
in `inputs`. Pandas will extract the arrays and call the ufunc again.
151152
2. You define a ``_HANDLED_TYPES`` tuple as an attribute on the class.
152153
Pandas inspect this to determine whether the ufunc is valid for the
@@ -861,6 +862,27 @@ def copy(self) -> ABCExtensionArray:
861862
"""
862863
raise AbstractMethodError(self)
863864

865+
def view(self, dtype=None) -> Union[ABCExtensionArray, np.ndarray]:
866+
"""
867+
Return a view on the array.
868+
869+
Parameters
870+
----------
871+
dtype : str, np.dtype, or ExtensionDtype, optional
872+
Default None
873+
874+
Returns
875+
-------
876+
ExtensionArray
877+
"""
878+
# NB:
879+
# - This must return a *new* object referencing the same data, not self.
880+
# - The only case that *must* be implemented is with dtype=None,
881+
# giving a view with the same dtype as self.
882+
if dtype is not None:
883+
raise NotImplementedError(dtype)
884+
return self[:]
885+
864886
# ------------------------------------------------------------------------
865887
# Printing
866888
# ------------------------------------------------------------------------

pandas/core/arrays/categorical.py

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
)
7878

7979

80-
def _cat_compare_op(op):
80+
def _cat_compare_op(opname):
8181
def f(self, other):
8282
# On python2, you can usually compare any type to any type, and
8383
# Categoricals can be seen as a custom type, but having different
@@ -90,7 +90,7 @@ def f(self, other):
9090
other = lib.item_from_zerodim(other)
9191

9292
if not self.ordered:
93-
if op in ["__lt__", "__gt__", "__le__", "__ge__"]:
93+
if opname in ["__lt__", "__gt__", "__le__", "__ge__"]:
9494
raise TypeError(
9595
"Unordered Categoricals can only compare equality or not"
9696
)
@@ -117,7 +117,7 @@ def f(self, other):
117117
other_codes = other._codes
118118

119119
mask = (self._codes == -1) | (other_codes == -1)
120-
f = getattr(self._codes, op)
120+
f = getattr(self._codes, opname)
121121
ret = f(other_codes)
122122
if mask.any():
123123
# In other series, the leads to False, so do that here too
@@ -127,38 +127,38 @@ def f(self, other):
127127
if is_scalar(other):
128128
if other in self.categories:
129129
i = self.categories.get_loc(other)
130-
ret = getattr(self._codes, op)(i)
130+
ret = getattr(self._codes, opname)(i)
131131

132132
# check for NaN in self
133133
mask = self._codes == -1
134134
ret[mask] = False
135135
return ret
136136
else:
137-
if op == "__eq__":
137+
if opname == "__eq__":
138138
return np.repeat(False, len(self))
139-
elif op == "__ne__":
139+
elif opname == "__ne__":
140140
return np.repeat(True, len(self))
141141
else:
142142
msg = (
143143
"Cannot compare a Categorical for op {op} with a "
144144
"scalar, which is not a category."
145145
)
146-
raise TypeError(msg.format(op=op))
146+
raise TypeError(msg.format(op=opname))
147147
else:
148148

149149
# allow categorical vs object dtype array comparisons for equality
150150
# these are only positional comparisons
151-
if op in ["__eq__", "__ne__"]:
152-
return getattr(np.array(self), op)(np.array(other))
151+
if opname in ["__eq__", "__ne__"]:
152+
return getattr(np.array(self), opname)(np.array(other))
153153

154154
msg = (
155155
"Cannot compare a Categorical for op {op} with type {typ}."
156156
"\nIf you want to compare values, use 'np.asarray(cat) "
157157
"<op> other'."
158158
)
159-
raise TypeError(msg.format(op=op, typ=type(other)))
159+
raise TypeError(msg.format(op=opname, typ=type(other)))
160160

161-
f.__name__ = op
161+
f.__name__ = opname
162162

163163
return f
164164

@@ -516,19 +516,12 @@ def astype(self, dtype: Dtype, copy: bool = True) -> ArrayLike:
516516
return self._set_dtype(dtype)
517517
return np.array(self, dtype=dtype, copy=copy)
518518

519-
@cache_readonly
520-
def ndim(self) -> int:
521-
"""
522-
Number of dimensions of the Categorical
523-
"""
524-
return self._codes.ndim
525-
526519
@cache_readonly
527520
def size(self) -> int:
528521
"""
529522
return the len of myself
530523
"""
531-
return len(self)
524+
return self._codes.size
532525

533526
@cache_readonly
534527
def itemsize(self) -> int:
@@ -1763,18 +1756,10 @@ def ravel(self, order="C"):
17631756
)
17641757
return np.array(self)
17651758

1766-
def view(self):
1767-
"""
1768-
Return a view of myself.
1769-
1770-
For internal compatibility with numpy arrays.
1771-
1772-
Returns
1773-
-------
1774-
view : Categorical
1775-
Returns `self`!
1776-
"""
1777-
return self
1759+
def view(self, dtype=None):
1760+
if dtype is not None:
1761+
raise NotImplementedError(dtype)
1762+
return self._constructor(values=self._codes, dtype=self.dtype, fastpath=True)
17781763

17791764
def to_dense(self):
17801765
"""

pandas/core/arrays/datetimelike.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -544,18 +544,8 @@ def astype(self, dtype, copy=True):
544544
return np.asarray(self, dtype=dtype)
545545

546546
def view(self, dtype=None):
547-
"""
548-
New view on this array with the same data.
549-
550-
Parameters
551-
----------
552-
dtype : numpy dtype, optional
553-
554-
Returns
555-
-------
556-
ndarray
557-
With the specified `dtype`.
558-
"""
547+
if dtype is None or dtype is self.dtype:
548+
return type(self)(self._data, dtype=self.dtype)
559549
return self._data.view(dtype=dtype)
560550

561551
# ------------------------------------------------------------------

pandas/core/arrays/interval.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -695,18 +695,14 @@ def isna(self):
695695
return isna(self.left)
696696

697697
@property
698-
def nbytes(self):
698+
def nbytes(self) -> int:
699699
return self.left.nbytes + self.right.nbytes
700700

701701
@property
702-
def size(self):
702+
def size(self) -> int:
703703
# Avoid materializing self.values
704704
return self.left.size
705705

706-
@property
707-
def shape(self):
708-
return self.left.shape
709-
710706
def take(self, indices, allow_fill=False, fill_value=None, axis=None, **kwargs):
711707
"""
712708
Take elements from the IntervalArray.

pandas/core/arrays/numpy_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ def __setitem__(self, key, value):
245245
else:
246246
self._ndarray[key] = value
247247

248-
def __len__(self):
248+
def __len__(self) -> int:
249249
return len(self._ndarray)
250250

251251
@property
252-
def nbytes(self):
252+
def nbytes(self) -> int:
253253
return self._ndarray.nbytes
254254

255255
def isna(self):

0 commit comments

Comments
 (0)