Skip to content

Commit 85db060

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into bug-cdt-eq
2 parents df64bcd + d210962 commit 85db060

29 files changed

+237
-261
lines changed

.github/workflows/ci.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,10 @@ jobs:
7474
asv check -E existing
7575
git remote add upstream https://github.com/pandas-dev/pandas.git
7676
git fetch upstream
77-
if git diff upstream/master --name-only | grep -q "^asv_bench/"; then
78-
asv machine --yes
79-
asv dev | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log
80-
if grep "failed" benchmarks.log > /dev/null ; then
81-
exit 1
82-
fi
83-
else
84-
echo "Benchmarks did not run, no changes detected"
77+
asv machine --yes
78+
asv dev | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log
79+
if grep "failed" benchmarks.log > /dev/null ; then
80+
exit 1
8581
fi
8682
if: always()
8783

.pre-commit-config.yaml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
minimum_pre_commit_version: '2.9.2'
12
repos:
23
- repo: https://github.com/python/black
34
rev: 20.8b1
@@ -21,10 +22,8 @@ repos:
2122
rev: 5.6.4
2223
hooks:
2324
- id: isort
24-
name: isort (python)
25-
- id: isort
26-
name: isort (cython)
27-
types: [cython]
25+
types: [text] # overwrite upstream `types: [python]`
26+
types_or: [python, cython]
2827
- repo: https://github.com/asottile/pyupgrade
2928
rev: v2.7.4
3029
hooks:
@@ -96,17 +95,17 @@ repos:
9695
name: Check for incorrect code block or IPython directives
9796
language: pygrep
9897
entry: (\.\. code-block ::|\.\. ipython ::)
99-
files: \.(py|pyx|rst)$
98+
types_or: [python, cython, rst]
10099
- id: unwanted-patterns-strings-to-concatenate
101100
name: Check for use of not concatenated strings
102101
language: python
103102
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
104-
files: \.(py|pyx|pxd|pxi)$
103+
types_or: [python, cython]
105104
- id: unwanted-patterns-strings-with-wrong-placed-whitespace
106105
name: Check for strings with wrong placed spaces
107106
language: python
108107
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
109-
files: \.(py|pyx|pxd|pxi)$
108+
types_or: [python, cython]
110109
- id: unwanted-patterns-private-import-across-module
111110
name: Check for import of private attributes across modules
112111
language: python

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The source code is currently hosted on GitHub at:
8787
https://github.com/pandas-dev/pandas
8888

8989
Binary installers for the latest released version are available at the [Python
90-
package index](https://pypi.org/project/pandas) and on conda.
90+
Package Index (PyPI)](https://pypi.org/project/pandas) and on [Conda](https://docs.conda.io/en/latest/).
9191

9292
```sh
9393
# conda
@@ -100,15 +100,15 @@ pip install pandas
100100
```
101101

102102
## Dependencies
103-
- [NumPy](https://www.numpy.org)
104-
- [python-dateutil](https://labix.org/python-dateutil)
105-
- [pytz](https://pythonhosted.org/pytz)
103+
- [NumPy - Adds support for large, multi-dimensional arrays, matrices and high-level mathematical functions to operate on these arrays](https://www.numpy.org)
104+
- [python-dateutil - Provides powerful extensions to the standard datetime module](https://labix.org/python-dateutil)
105+
- [pytz - Brings the Olson tz database into Python which allows accurate and cross platform timezone calculations](https://pythonhosted.org/pytz)
106106

107107
See the [full installation instructions](https://pandas.pydata.org/pandas-docs/stable/install.html#dependencies) for minimum supported versions of required, recommended and optional dependencies.
108108

109109
## Installation from sources
110-
To install pandas from source you need Cython in addition to the normal
111-
dependencies above. Cython can be installed from pypi:
110+
To install pandas from source you need [Cython](https://cython.org/) in addition to the normal
111+
dependencies above. Cython can be installed from PyPI:
112112

113113
```sh
114114
pip install cython
@@ -145,7 +145,7 @@ See the full instructions for [installing from source](https://pandas.pydata.org
145145
The official documentation is hosted on PyData.org: https://pandas.pydata.org/pandas-docs/stable
146146

147147
## Background
148-
Work on ``pandas`` started at AQR (a quantitative hedge fund) in 2008 and
148+
Work on ``pandas`` started at [AQR](https://www.aqr.com/) (a quantitative hedge fund) in 2008 and
149149
has been under active development since then.
150150

151151
## Getting Help

asv_bench/benchmarks/indexing.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
lower-level methods directly on Index and subclasses, see index_object.py,
44
indexing_engine.py, and index_cached.py
55
"""
6+
import string
67
import warnings
78

89
import numpy as np
@@ -255,6 +256,7 @@ def setup(self, index):
255256
"non_monotonic": CategoricalIndex(list("abc" * N)),
256257
}
257258
self.data = indices[index]
259+
self.data_unique = CategoricalIndex(list(string.printable))
258260

259261
self.int_scalar = 10000
260262
self.int_list = list(range(10000))
@@ -281,7 +283,7 @@ def time_get_loc_scalar(self, index):
281283
self.data.get_loc(self.cat_scalar)
282284

283285
def time_get_indexer_list(self, index):
284-
self.data.get_indexer(self.cat_list)
286+
self.data_unique.get_indexer(self.cat_list)
285287

286288

287289
class MethodLookup:

ci/deps/azure-37-slow.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies:
3131
- moto>=1.3.14
3232
- scipy
3333
- sqlalchemy
34-
- xlrd
34+
- xlrd<2.0
3535
- xlsxwriter
3636
- xlwt
3737
- moto

ci/deps/azure-38-locale.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies:
3030
- pytz
3131
- scipy
3232
- xarray
33-
- xlrd
33+
- xlrd<2.0
3434
- xlsxwriter
3535
- xlwt
3636
- moto

ci/deps/azure-macos-37.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- python-dateutil==2.7.3
2727
- pytz
2828
- xarray
29-
- xlrd
29+
- xlrd<2.0
3030
- xlsxwriter
3131
- xlwt
3232
- pip

ci/deps/azure-windows-37.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies:
3333
- s3fs>=0.4.2
3434
- scipy
3535
- sqlalchemy
36-
- xlrd
36+
- xlrd<2.0
3737
- xlsxwriter
3838
- xlwt
3939
- pyreadstat

ci/deps/azure-windows-38.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ dependencies:
3131
- pytz
3232
- s3fs>=0.4.0
3333
- scipy
34-
- xlrd
34+
- xlrd<2.0
3535
- xlsxwriter
3636
- xlwt

ci/deps/travis-37-cov.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies:
4343
- sqlalchemy
4444
- statsmodels
4545
- xarray
46-
- xlrd
46+
- xlrd<2.0
4747
- xlsxwriter
4848
- xlwt
4949
- pip

ci/deps/travis-37-locale.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies:
3535
- pytables>=3.5.1
3636
- scipy
3737
- xarray=0.12.3
38-
- xlrd
38+
- xlrd<2.0
3939
- xlsxwriter
4040
- xlwt
4141
- moto

ci/deps/travis-38-slow.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies:
3030
- moto>=1.3.14
3131
- scipy
3232
- sqlalchemy
33-
- xlrd
33+
- xlrd<2.0
3434
- xlsxwriter
3535
- xlwt
3636
- moto

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies:
2424
- flake8-comprehensions>=3.1.0 # used by flake8, linting of unnecessary comprehensions
2525
- isort>=5.2.1 # check that imports are in the right order
2626
- mypy=0.782
27-
- pre-commit
27+
- pre-commit>=2.9.2
2828
- pycodestyle # used by flake8
2929
- pyupgrade
3030

pandas/_libs/lib.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ def infer_dtype(value: object, skipna: bool = True) -> str:
13131313
'boolean'
13141314

13151315
>>> infer_dtype([True, False, np.nan])
1316-
'mixed'
1316+
'boolean'
13171317

13181318
>>> infer_dtype([pd.Timestamp('20130101')])
13191319
'datetime'

pandas/_typing.py

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
IndexLabel = Union[Label, Sequence[Label]]
9696
Level = Union[Label, int]
9797
Shape = Tuple[int, ...]
98+
Suffixes = Tuple[str, str]
9899
Ordered = Optional[bool]
99100
JSONSerializable = Optional[Union[PythonScalar, List, Dict]]
100101
Axes = Collection

pandas/core/arrays/timedeltas.py

+6-14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
)
2525
from pandas.compat.numpy import function as nv
2626

27+
from pandas.core.dtypes.cast import astype_td64_unit_conversion
2728
from pandas.core.dtypes.common import (
2829
DT64NS_DTYPE,
2930
TD64NS_DTYPE,
@@ -35,7 +36,6 @@
3536
is_scalar,
3637
is_string_dtype,
3738
is_timedelta64_dtype,
38-
is_timedelta64_ns_dtype,
3939
pandas_dtype,
4040
)
4141
from pandas.core.dtypes.dtypes import DatetimeTZDtype
@@ -324,22 +324,14 @@ def astype(self, dtype, copy: bool = True):
324324
# DatetimeLikeArrayMixin super call handles other cases
325325
dtype = pandas_dtype(dtype)
326326

327-
if is_timedelta64_dtype(dtype) and not is_timedelta64_ns_dtype(dtype):
328-
# by pandas convention, converting to non-nano timedelta64
329-
# returns an int64-dtyped array with ints representing multiples
330-
# of the desired timedelta unit. This is essentially division
331-
if self._hasnans:
332-
# avoid double-copying
333-
result = self._data.astype(dtype, copy=False)
334-
return self._maybe_mask_results(
335-
result, fill_value=None, convert="float64"
336-
)
337-
result = self._data.astype(dtype, copy=copy)
338-
return result.astype("i8")
339-
elif is_timedelta64_ns_dtype(dtype):
327+
if is_dtype_equal(dtype, self.dtype):
340328
if copy:
341329
return self.copy()
342330
return self
331+
332+
elif dtype.kind == "m":
333+
return astype_td64_unit_conversion(self._data, dtype, copy=copy)
334+
343335
return dtl.DatetimeLikeArrayMixin.astype(self, dtype, copy=copy)
344336

345337
def __iter__(self):

0 commit comments

Comments
 (0)