Skip to content

Commit f958bbd

Browse files
committed
Merge remote-tracking branch 'upstream/master' into sort
2 parents accf764 + d5fa16b commit f958bbd

File tree

25 files changed

+228
-141
lines changed

25 files changed

+228
-141
lines changed

ci/deps/travis-36-cov.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies:
2929
- python-snappy
3030
- python=3.6.*
3131
- pytz
32-
- s3fs
32+
- s3fs<0.3
3333
- scikit-learn
3434
- scipy
3535
- sqlalchemy

ci/deps/travis-36-slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818
- python-dateutil
1919
- python=3.6.*
2020
- pytz
21-
- s3fs
21+
- s3fs<0.3
2222
- scipy
2323
- sqlalchemy
2424
- xlrd

ci/deps/travis-37.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
- pytest-xdist>=1.29.0
1818
- pytest-mock
1919
- hypothesis>=3.58.0
20-
- s3fs
20+
- s3fs<0.3
2121
- pip
2222
- pyreadstat
2323
- pip:

doc/source/whatsnew/v1.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ Reshaping
279279

280280
- Bug in :meth:`DataFrame.apply` that caused incorrect output with empty :class:`DataFrame` (:issue:`28202`, :issue:`21959`)
281281
- Bug in :meth:`DataFrame.stack` not handling non-unique indexes correctly when creating MultiIndex (:issue: `28301`)
282+
- Bug :func:`merge_asof` could not use :class:`datetime.timedelta` for ``tolerance`` kwarg (:issue:`28098`)
282283

283284
Sparse
284285
^^^^^^

pandas/_libs/tslibs/conversion.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ cdef _TSObject convert_str_to_tsobject(object ts, object tz, object unit,
519519
try:
520520
ts = parse_datetime_string(ts, dayfirst=dayfirst,
521521
yearfirst=yearfirst)
522-
except Exception:
522+
except (ValueError, OverflowError):
523523
raise ValueError("could not convert string to Timestamp")
524524

525525
return convert_to_tsobject(ts, tz, unit, dayfirst, yearfirst)

pandas/_libs/tslibs/parsing.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ cdef parse_datetime_string_with_reso(date_string, freq=None, dayfirst=False,
309309
parsed, reso = dateutil_parse(date_string, _DEFAULT_DATETIME,
310310
dayfirst=dayfirst, yearfirst=yearfirst,
311311
ignoretz=False, tzinfos=None)
312-
except Exception as e:
312+
except (ValueError, OverflowError) as err:
313313
# TODO: allow raise of errors within instead
314-
raise DateParseError(e)
314+
raise DateParseError(err)
315315
if parsed is None:
316316
raise DateParseError("Could not parse {dstr}".format(dstr=date_string))
317317
return parsed, parsed, reso

pandas/core/reshape/merge.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import copy
6+
import datetime
67
from functools import partial
78
import string
89
import warnings
@@ -1619,7 +1620,7 @@ def _get_merge_keys(self):
16191620
)
16201621
raise MergeError(msg)
16211622

1622-
# validate tolerance; must be a Timedelta if we have a DTI
1623+
# validate tolerance; datetime.timedelta or Timedelta if we have a DTI
16231624
if self.tolerance is not None:
16241625

16251626
if self.left_index:
@@ -1635,7 +1636,7 @@ def _get_merge_keys(self):
16351636
)
16361637

16371638
if is_datetimelike(lt):
1638-
if not isinstance(self.tolerance, Timedelta):
1639+
if not isinstance(self.tolerance, datetime.timedelta):
16391640
raise MergeError(msg)
16401641
if self.tolerance < Timedelta(0):
16411642
raise MergeError("tolerance must be positive")
@@ -1705,6 +1706,7 @@ def flip(xs):
17051706
left_values = left_values.view("i8")
17061707
right_values = right_values.view("i8")
17071708
if tolerance is not None:
1709+
tolerance = Timedelta(tolerance)
17081710
tolerance = tolerance.value
17091711

17101712
# a "by" parameter requires special handling

pandas/plotting/_matplotlib/tools.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,15 @@ def _remove_labels_from_axis(axis):
281281
for t in axis.get_majorticklabels():
282282
t.set_visible(False)
283283

284-
try:
285-
# set_visible will not be effective if
286-
# minor axis has NullLocator and NullFormattor (default)
287-
if isinstance(axis.get_minor_locator(), ticker.NullLocator):
288-
axis.set_minor_locator(ticker.AutoLocator())
289-
if isinstance(axis.get_minor_formatter(), ticker.NullFormatter):
290-
axis.set_minor_formatter(ticker.FormatStrFormatter(""))
291-
for t in axis.get_minorticklabels():
292-
t.set_visible(False)
293-
except Exception: # pragma no cover
294-
raise
284+
# set_visible will not be effective if
285+
# minor axis has NullLocator and NullFormattor (default)
286+
if isinstance(axis.get_minor_locator(), ticker.NullLocator):
287+
axis.set_minor_locator(ticker.AutoLocator())
288+
if isinstance(axis.get_minor_formatter(), ticker.NullFormatter):
289+
axis.set_minor_formatter(ticker.FormatStrFormatter(""))
290+
for t in axis.get_minorticklabels():
291+
t.set_visible(False)
292+
295293
axis.get_label().set_visible(False)
296294

297295

pandas/tests/groupby/test_categorical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ def test_categorical_no_compress():
782782

783783
def test_sort():
784784

785-
# http://stackoverflow.com/questions/23814368/sorting-pandas-categorical-labels-after-groupby # noqa: flake8
785+
# http://stackoverflow.com/questions/23814368/sorting-pandas-categorical-labels-after-groupby # noqa: E501
786786
# This should result in a properly sorted Series so that the plot
787787
# has a sorted x axis
788788
# self.cat.groupby(['value_group'])['value_group'].count().plot(kind='bar')

pandas/tests/reshape/merge/test_merge_asof.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,7 @@ def test_non_sorted(self):
592592

593593
@pytest.mark.parametrize(
594594
"tolerance",
595-
[
596-
Timedelta("1day"),
597-
pytest.param(
598-
datetime.timedelta(days=1),
599-
marks=pytest.mark.xfail(reason="not implemented", strict=True),
600-
),
601-
],
595+
[Timedelta("1day"), datetime.timedelta(days=1)],
602596
ids=["pd.Timedelta", "datetime.timedelta"],
603597
)
604598
def test_tolerance(self, tolerance):

0 commit comments

Comments
 (0)