Skip to content

Commit 1e36f78

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into cln-pytables8
2 parents 4693b9b + d56c2dc commit 1e36f78

File tree

110 files changed

+472
-666
lines changed

Some content is hidden

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

110 files changed

+472
-666
lines changed

ci/code_checks.sh

+4
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
194194
invgrep -R --include="*.py" --include="*.pyx" -E 'class.*:\n\n( )+"""' .
195195
RET=$(($RET + $?)) ; echo $MSG "DONE"
196196

197+
MSG='Check for use of comment-based annotation syntax' ; echo $MSG
198+
invgrep -R --include="*.py" -P '# type: (?!ignore)' pandas
199+
RET=$(($RET + $?)) ; echo $MSG "DONE"
200+
197201
MSG='Check that no file in the repo contains trailing whitespaces' ; echo $MSG
198202
set -o pipefail
199203
if [[ "$AZURE" == "true" ]]; then

ci/deps/azure-36-32bit.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dependencies:
88
# tools
99
### Cython 0.29.13 and pytest 5.0.1 for 32 bits are not available with conda, installing below with pip instead
1010
- pytest-xdist>=1.21
11-
- pytest-mock
1211
- hypothesis>=3.58.0
1312
- pytest-azurepipelines
1413

ci/deps/azure-36-locale.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413
- pytest-azurepipelines
1514

ci/deps/azure-36-locale_slow.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413
- pytest-azurepipelines
1514

ci/deps/azure-36-minimum_versions.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython=0.29.13
1010
- pytest=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413
- pytest-azurepipelines
1514

ci/deps/azure-37-locale.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413
- pytest-azurepipelines
1514

ci/deps/azure-37-numpydev.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dependencies:
88
- cython>=0.29.13
99
- pytest>=5.0.1
1010
- pytest-xdist>=1.21
11-
- pytest-mock
1211
- hypothesis>=3.58.0
1312
- pytest-azurepipelines
1413

ci/deps/azure-macos-36.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dependencies:
88
- cython>=0.29.13
99
- pytest>=5.0.1
1010
- pytest-xdist>=1.21
11-
- pytest-mock
1211
- hypothesis>=3.58.0
1312
- pytest-azurepipelines
1413

ci/deps/azure-windows-36.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413
- pytest-azurepipelines
1514

ci/deps/azure-windows-37.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413
- pytest-azurepipelines
1514

ci/deps/travis-36-cov.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413
- pytest-cov # this is only needed in the coverage build
1514

ci/deps/travis-36-locale.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413

1514
# pandas dependencies

ci/deps/travis-36-slow.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12-
- pytest-mock
1312
- hypothesis>=3.58.0
1413

1514
# pandas dependencies

ci/deps/travis-37.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dependencies:
1010
- cython>=0.29.13
1111
- pytest>=5.0.1
1212
- pytest-xdist>=1.21
13-
- pytest-mock
1413
- hypothesis>=3.58.0
1514

1615
# pandas dependencies

ci/deps/travis-38.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
# tools
99
- cython>=0.29.13
1010
- pytest>=5.0.1
11-
- pytest-xdist>=1.29.0 # The rest of the builds use >=1.21, and use pytest-mock
11+
- pytest-xdist>=1.21
1212
- hypothesis>=3.58.0
1313

1414
# pandas dependencies

doc/source/development/contributing.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -804,27 +804,27 @@ Types imports should follow the ``from typing import ...`` convention. So rather
804804
805805
import typing
806806
807-
primes = [] # type: typing.List[int]
807+
primes: typing.List[int] = []
808808
809809
You should write
810810

811811
.. code-block:: python
812812
813813
from typing import List, Optional, Union
814814
815-
primes = [] # type: List[int]
815+
primes: List[int] = []
816816
817817
``Optional`` should be used where applicable, so instead of
818818

819819
.. code-block:: python
820820
821-
maybe_primes = [] # type: List[Union[int, None]]
821+
maybe_primes: List[Union[int, None]] = []
822822
823823
You should write
824824

825825
.. code-block:: python
826826
827-
maybe_primes = [] # type: List[Optional[int]]
827+
maybe_primes: List[Optional[int]] = []
828828
829829
In some cases in the code base classes may define class variables that shadow builtins. This causes an issue as described in `Mypy 1775 <https://github.com/python/mypy/issues/1775#issuecomment-310969854>`_. The defensive solution here is to create an unambiguous alias of the builtin and use that without your annotation. For example, if you come across a definition like
830830

@@ -840,7 +840,7 @@ The appropriate way to annotate this would be as follows
840840
str_type = str
841841
842842
class SomeClass2:
843-
str = None # type: str_type
843+
str: str_type = None
844844
845845
In some cases you may be tempted to use ``cast`` from the typing module when you know better than the analyzer. This occurs particularly when using custom inference functions. For example
846846

@@ -946,7 +946,7 @@ extensions in `numpy.testing
946946

947947
.. note::
948948

949-
The earliest supported pytest version is 4.0.2.
949+
The earliest supported pytest version is 5.0.1.
950950

951951
Writing tests
952952
~~~~~~~~~~~~~

doc/source/getting_started/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pandas is equipped with an exhaustive set of unit tests, covering about 97% of
177177
the code base as of this writing. To run it on your machine to verify that
178178
everything is working (and that you have all of the dependencies, soft and hard,
179179
installed), make sure you have `pytest
180-
<http://docs.pytest.org/en/latest/>`__ >= 4.0.2 and `Hypothesis
180+
<http://docs.pytest.org/en/latest/>`__ >= 5.0.1 and `Hypothesis
181181
<https://hypothesis.readthedocs.io/>`__ >= 3.58, then run:
182182

183183
::

doc/source/whatsnew/v1.0.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ Other API changes
253253
See :ref:`units registration <whatsnew_1000.matplotlib_units>` for more.
254254
- :meth:`Series.dropna` has dropped its ``**kwargs`` argument in favor of a single ``how`` parameter.
255255
Supplying anything else than ``how`` to ``**kwargs`` raised a ``TypeError`` previously (:issue:`29388`)
256+
- When testing pandas, the new minimum required version of pytest is 5.0.1 (:issue:`29664`)
256257
-
257258

258259

@@ -321,6 +322,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
321322
- :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`)
322323
- :meth:`pandas.Series.str.cat` does not accept list-likes *within* list-likes anymore (:issue:`27611`)
323324
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
325+
- Removed support for legacy HDF5 formats (:issue:`29787`)
324326
- :func:`read_excel` removed support for "skip_footer" argument, use "skipfooter" instead (:issue:`18836`)
325327
- :meth:`DataFrame.to_records` no longer supports the argument "convert_datetime64" (:issue:`18902`)
326328
- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`)
@@ -487,6 +489,7 @@ I/O
487489
- Bug in :meth:`Styler.background_gradient` not able to work with dtype ``Int64`` (:issue:`28869`)
488490
- Bug in :meth:`DataFrame.to_clipboard` which did not work reliably in ipython (:issue:`22707`)
489491
- Bug in :func:`read_json` where default encoding was not set to ``utf-8`` (:issue:`29565`)
492+
- Bug in :class:`PythonParser` where str and bytes were being mixed when dealing with the decimal field (:issue:`29650`)
490493
-
491494

492495
Plotting

pandas/_config/config.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@
5858
RegisteredOption = namedtuple("RegisteredOption", "key defval doc validator cb")
5959

6060
# holds deprecated option metdata
61-
_deprecated_options = {} # type: Dict[str, DeprecatedOption]
61+
_deprecated_options: Dict[str, DeprecatedOption] = {}
6262

6363
# holds registered option metdata
64-
_registered_options = {} # type: Dict[str, RegisteredOption]
64+
_registered_options: Dict[str, RegisteredOption] = {}
6565

6666
# holds the current values for registered options
67-
_global_config = {} # type: Dict[str, str]
67+
_global_config: Dict[str, str] = {}
6868

6969
# keys which have a special meaning
70-
_reserved_keys = ["all"] # type: List[str]
70+
_reserved_keys: List[str] = ["all"]
7171

7272

7373
class OptionError(AttributeError, KeyError):

pandas/_libs/parsers.pyx

-53
Original file line numberDiff line numberDiff line change
@@ -1406,59 +1406,6 @@ cdef inline StringPath _string_path(char *encoding):
14061406
# Type conversions / inference support code
14071407

14081408

1409-
cdef _string_box_factorize(parser_t *parser, int64_t col,
1410-
int64_t line_start, int64_t line_end,
1411-
bint na_filter, kh_str_starts_t *na_hashset):
1412-
cdef:
1413-
int error, na_count = 0
1414-
Py_ssize_t i, lines
1415-
coliter_t it
1416-
const char *word = NULL
1417-
ndarray[object] result
1418-
1419-
int ret = 0
1420-
kh_strbox_t *table
1421-
1422-
object pyval
1423-
1424-
object NA = na_values[np.object_]
1425-
khiter_t k
1426-
1427-
table = kh_init_strbox()
1428-
lines = line_end - line_start
1429-
result = np.empty(lines, dtype=np.object_)
1430-
coliter_setup(&it, parser, col, line_start)
1431-
1432-
for i in range(lines):
1433-
COLITER_NEXT(it, word)
1434-
1435-
if na_filter:
1436-
if kh_get_str_starts_item(na_hashset, word):
1437-
# in the hash table
1438-
na_count += 1
1439-
result[i] = NA
1440-
continue
1441-
1442-
k = kh_get_strbox(table, word)
1443-
1444-
# in the hash table
1445-
if k != table.n_buckets:
1446-
# this increments the refcount, but need to test
1447-
pyval = <object>table.vals[k]
1448-
else:
1449-
# box it. new ref?
1450-
pyval = PyBytes_FromString(word)
1451-
1452-
k = kh_put_strbox(table, word, &ret)
1453-
table.vals[k] = <PyObject*>pyval
1454-
1455-
result[i] = pyval
1456-
1457-
kh_destroy_strbox(table)
1458-
1459-
return result, na_count
1460-
1461-
14621409
cdef _string_box_utf8(parser_t *parser, int64_t col,
14631410
int64_t line_start, int64_t line_end,
14641411
bint na_filter, kh_str_starts_t *na_hashset):

pandas/_libs/src/ujson/python/objToJSON.c

-16
Original file line numberDiff line numberDiff line change
@@ -399,22 +399,6 @@ static void *CLong(JSOBJ obj, JSONTypeContext *tc, void *outValue,
399399
return NULL;
400400
}
401401

402-
#ifdef _LP64
403-
static void *PyIntToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
404-
size_t *_outLen) {
405-
PyObject *obj = (PyObject *)_obj;
406-
*((JSINT64 *)outValue) = PyLong_AsLong(obj);
407-
return NULL;
408-
}
409-
#else
410-
static void *PyIntToINT32(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
411-
size_t *_outLen) {
412-
PyObject *obj = (PyObject *)_obj;
413-
*((JSINT32 *)outValue) = PyLong_AsLong(obj);
414-
return NULL;
415-
}
416-
#endif
417-
418402
static void *PyLongToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue,
419403
size_t *_outLen) {
420404
*((JSINT64 *)outValue) = GET_TC(tc)->longValue;

pandas/_libs/tslibs/c_timestamp.pyx

+11-13
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def maybe_integer_op_deprecated(obj):
5555
# GH#22535 add/sub of integers and int-arrays is deprecated
5656
if obj.freq is not None:
5757
warnings.warn("Addition/subtraction of integers and integer-arrays "
58-
"to {cls} is deprecated, will be removed in a future "
58+
f"to {type(obj).__name__} is deprecated, "
59+
"will be removed in a future "
5960
"version. Instead of adding/subtracting `n`, use "
6061
"`n * self.freq`"
61-
.format(cls=type(obj).__name__),
62-
FutureWarning)
62+
, FutureWarning)
6363

6464

6565
cdef class _Timestamp(datetime):
@@ -144,11 +144,10 @@ cdef class _Timestamp(datetime):
144144
# e.g. tzlocal has no `strftime`
145145
pass
146146

147-
tz = ", tz='{0}'".format(zone) if zone is not None else ""
148-
freq = "" if self.freq is None else ", freq='{0}'".format(self.freqstr)
147+
tz = f", tz='{zone}'" if zone is not None else ""
148+
freq = "" if self.freq is None else f", freq='{self.freqstr}'"
149149

150-
return "Timestamp('{stamp}'{tz}{freq})".format(stamp=stamp,
151-
tz=tz, freq=freq)
150+
return f"Timestamp('{stamp}'{tz}{freq})"
152151

153152
cdef bint _compare_outside_nanorange(_Timestamp self, datetime other,
154153
int op) except -1:
@@ -370,23 +369,22 @@ cdef class _Timestamp(datetime):
370369

371370
@property
372371
def _repr_base(self) -> str:
373-
return '{date} {time}'.format(date=self._date_repr,
374-
time=self._time_repr)
372+
return f"{self._date_repr} {self._time_repr}"
375373

376374
@property
377375
def _date_repr(self) -> str:
378376
# Ideal here would be self.strftime("%Y-%m-%d"), but
379377
# the datetime strftime() methods require year >= 1900
380-
return '%d-%.2d-%.2d' % (self.year, self.month, self.day)
378+
return f'{self.year}-{self.month:02d}-{self.day:02d}'
381379

382380
@property
383381
def _time_repr(self) -> str:
384-
result = '%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second)
382+
result = f'{self.hour:02d}:{self.minute:02d}:{self.second:02d}'
385383

386384
if self.nanosecond != 0:
387-
result += '.%.9d' % (self.nanosecond + 1000 * self.microsecond)
385+
result += f'.{self.nanosecond + 1000 * self.microsecond:09d}'
388386
elif self.microsecond != 0:
389-
result += '.%.6d' % self.microsecond
387+
result += f'.{self.microsecond:06d}'
390388

391389
return result
392390

pandas/_libs/tslibs/conversion.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def datetime_to_datetime64(object[:] values):
197197
iresult[i] = pydatetime_to_dt64(val, &dts)
198198
check_dts_bounds(&dts)
199199
else:
200-
raise TypeError('Unrecognized value type: %s' % type(val))
200+
raise TypeError(f'Unrecognized value type: {type(val)}')
201201

202202
return result, inferred_tz
203203

@@ -326,8 +326,8 @@ cdef convert_to_tsobject(object ts, object tz, object unit,
326326
raise ValueError("Cannot convert Period to Timestamp "
327327
"unambiguously. Use to_timestamp")
328328
else:
329-
raise TypeError('Cannot convert input [{}] of type {} to '
330-
'Timestamp'.format(ts, type(ts)))
329+
raise TypeError(f'Cannot convert input [{ts}] of type {type(ts)} to '
330+
f'Timestamp')
331331

332332
if tz is not None:
333333
localize_tso(obj, tz)
@@ -686,7 +686,7 @@ def normalize_date(dt: object) -> datetime:
686686
elif PyDate_Check(dt):
687687
return datetime(dt.year, dt.month, dt.day)
688688
else:
689-
raise TypeError('Unrecognized type: %s' % type(dt))
689+
raise TypeError(f'Unrecognized type: {type(dt)}')
690690

691691

692692
@cython.wraparound(False)

0 commit comments

Comments
 (0)