Skip to content

Commit 4a4f3f2

Browse files
author
harisbal
committed
Rebase
Rebase
1 parent dc4bf8a commit 4a4f3f2

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed

ci/requirements-3.6.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ python=3.6*
22
python-dateutil
33
pytz
44
nomkl
5-
numpy
5+
numpy=1.13.*
66
cython

pandas/core/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class StringMixin(object):
4646
# Formatting
4747

4848
def __unicode__(self):
49-
raise AbstractMethodError(self)
49+
raise com.AbstractMethodError(self)
5050

5151
def __str__(self):
5252
"""
@@ -278,10 +278,10 @@ def _gotitem(self, key, ndim, subset=None):
278278
subset to act on
279279
280280
"""
281-
raise AbstractMethodError(self)
281+
raise com.AbstractMethodError(self)
282282

283283
def aggregate(self, func, *args, **kwargs):
284-
raise AbstractMethodError(self)
284+
raise com.AbstractMethodError(self)
285285

286286
agg = aggregate
287287

@@ -1247,4 +1247,4 @@ def duplicated(self, keep='first'):
12471247
# abstracts
12481248

12491249
def _update_inplace(self, result, **kwargs):
1250-
raise AbstractMethodError(self)
1250+
raise com.AbstractMethodError(self)

pandas/core/resample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _convert_obj(self, obj):
233233
return obj
234234

235235
def _get_binner_for_time(self):
236-
raise AbstractMethodError(self)
236+
raise com.AbstractMethodError(self)
237237

238238
def _set_binner(self):
239239
"""
@@ -372,10 +372,10 @@ def transform(self, arg, *args, **kwargs):
372372
arg, *args, **kwargs)
373373

374374
def _downsample(self, f):
375-
raise AbstractMethodError(self)
375+
raise com.AbstractMethodError(self)
376376

377377
def _upsample(self, f, limit=None, fill_value=None):
378-
raise AbstractMethodError(self)
378+
raise com.AbstractMethodError(self)
379379

380380
def _gotitem(self, key, ndim, subset=None):
381381
"""

pandas/tests/frame/test_operators.py

+47
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,53 @@
2828
_check_mixed_int)
2929

3030

31+
class TestDataFrameArithmetic(object):
32+
33+
@pytest.mark.xfail(reason='GH#7996 datetime64 units not converted to nano')
34+
def test_frame_sub_datetime64_not_ns(self):
35+
df = pd.DataFrame(date_range('20130101', periods=3))
36+
dt64 = np.datetime64('2013-01-01')
37+
assert dt64.dtype == 'datetime64[D]'
38+
res = df - dt64
39+
expected = pd.DataFrame([pd.Timedelta(days=0), pd.Timedelta(days=1),
40+
pd.Timedelta(days=2)])
41+
tm.assert_frame_equal(res, expected)
42+
43+
@pytest.mark.parametrize('data', [
44+
[1, 2, 3],
45+
[1.1, 2.2, 3.3],
46+
[pd.Timestamp('2011-01-01'), pd.Timestamp('2011-01-02'), pd.NaT],
47+
['x', 'y', 1]])
48+
@pytest.mark.parametrize('dtype', [None, object])
49+
def test_frame_radd_str_invalid(self, dtype, data):
50+
df = DataFrame(data, dtype=dtype)
51+
with pytest.raises(TypeError):
52+
'foo_' + df
53+
54+
@pytest.mark.parametrize('dtype', [None, object])
55+
def test_frame_with_dtype_radd_int(self, dtype):
56+
df = pd.DataFrame([1, 2, 3], dtype=dtype)
57+
expected = pd.DataFrame([2, 3, 4], dtype=dtype)
58+
result = 1 + df
59+
assert_frame_equal(result, expected)
60+
result = df + 1
61+
assert_frame_equal(result, expected)
62+
63+
@pytest.mark.parametrize('dtype', [None, object])
64+
def test_frame_with_dtype_radd_nan(self, dtype):
65+
df = pd.DataFrame([1, 2, 3], dtype=dtype)
66+
expected = pd.DataFrame([np.nan, np.nan, np.nan], dtype=dtype)
67+
result = np.nan + df
68+
assert_frame_equal(result, expected)
69+
result = df + np.nan
70+
assert_frame_equal(result, expected)
71+
72+
def test_frame_radd_str(self):
73+
df = pd.DataFrame(['x', np.nan, 'x'])
74+
assert_frame_equal('a' + df, pd.DataFrame(['ax', np.nan, 'ax']))
75+
assert_frame_equal(df + 'a', pd.DataFrame(['xa', np.nan, 'xa']))
76+
77+
3178
class TestDataFrameOperators(TestData):
3279

3380
def test_operators(self):

0 commit comments

Comments
 (0)