Skip to content

ERR: better error reporting for failing parsing in timedelta/timeseries #10720 #10883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,8 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None,
bounds_error=bounds_error)
new_y = terp(new_x)
elif method == 'spline':
# GH #10633

# GH 10633
if not order:
raise ValueError("order needs to be specified and greater than 0")
terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs)
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,14 @@ def test_nan_interpolate(self):
tm._skip_if_no_scipy()
result = s.interpolate(method='polynomial', order=1)
assert_series_equal(result, expected)
# GH #10633: first attempt
def test_interpolate_spline(self):
np.random.seed(1)
s = pd.Series(np.arange(10)**2)
s[np.random.randint(0,9,3)] = np.nan
with tm.assertRaises(ValueError):
s.interpolate(method='spline')


def test_nan_irregular_index(self):
s = Series([1, 2, np.nan, 4], index=[1, 3, 5, 9])
Expand Down
4 changes: 2 additions & 2 deletions pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,8 @@ def test_to_datetime_with_apply(self):
assert_series_equal(result, expected)

td = pd.Series(['May 04', 'Jun 02', ''], index=[1,2,3])
self.assertRaises(ValueError, lambda : pd.to_datetime(td,format='%b %y', errors='raise'))
self.assertRaises(ValueError, lambda : td.apply(pd.to_datetime, format='%b %y', errors='raise'))
self.assertRaisesRegexp(ValueError, 'Unknown string format. You can coerce errors to NaT by passing coerce', lambda : pd.to_datetime(td,format='%b %y', errors='raise'))
self.assertRaisesRegexp(ValueError, 'Unknown string format. You can coerce errors to NaT by passing coerce',lambda : td.apply(pd.to_datetime, format='%b %y', errors='raise'))
expected = pd.to_datetime(td, format='%b %y', errors='coerce')

result = td.apply(lambda x: pd.to_datetime(x, format='%b %y', errors='coerce'))
Expand Down