|
10 | 10 | from numpy import nan, random
|
11 | 11 | import numpy as np
|
12 | 12 |
|
13 |
| -from pandas.compat import lrange, range |
| 13 | +from pandas.compat import range |
14 | 14 | from pandas import compat
|
15 | 15 | from pandas import (DataFrame, Series, MultiIndex, Timestamp,
|
16 | 16 | date_range)
|
|
28 | 28 | _check_mixed_int)
|
29 | 29 |
|
30 | 30 |
|
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 |
| - |
78 | 31 | class TestDataFrameOperators(TestData):
|
79 | 32 |
|
80 | 33 | def test_operators(self):
|
@@ -714,22 +667,6 @@ def _test_seq(df, idx_ser, col_ser):
|
714 | 667 | exp = DataFrame({'col': [False, True, False]})
|
715 | 668 | assert_frame_equal(result, exp)
|
716 | 669 |
|
717 |
| - def test_return_dtypes_bool_op_costant(self): |
718 |
| - # GH15077 |
719 |
| - df = DataFrame({'x': [1, 2, 3], 'y': [1., 2., 3.]}) |
720 |
| - const = 2 |
721 |
| - |
722 |
| - # not empty DataFrame |
723 |
| - for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']: |
724 |
| - result = getattr(df, op)(const).get_dtype_counts() |
725 |
| - tm.assert_series_equal(result, Series([2], ['bool'])) |
726 |
| - |
727 |
| - # empty DataFrame |
728 |
| - empty = df.iloc[:0] |
729 |
| - for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']: |
730 |
| - result = getattr(empty, op)(const).get_dtype_counts() |
731 |
| - tm.assert_series_equal(result, Series([2], ['bool'])) |
732 |
| - |
733 | 670 | def test_dti_tz_convert_to_utc(self):
|
734 | 671 | base = pd.DatetimeIndex(['2011-01-01', '2011-01-02',
|
735 | 672 | '2011-01-03'], tz='UTC')
|
@@ -1009,22 +946,6 @@ def test_comparison_protected_from_errstate(self):
|
1009 | 946 | result = (missing_df < 0).values
|
1010 | 947 | tm.assert_numpy_array_equal(result, expected)
|
1011 | 948 |
|
1012 |
| - def test_string_comparison(self): |
1013 |
| - df = DataFrame([{"a": 1, "b": "foo"}, {"a": 2, "b": "bar"}]) |
1014 |
| - mask_a = df.a > 1 |
1015 |
| - assert_frame_equal(df[mask_a], df.loc[1:1, :]) |
1016 |
| - assert_frame_equal(df[-mask_a], df.loc[0:0, :]) |
1017 |
| - |
1018 |
| - mask_b = df.b == "foo" |
1019 |
| - assert_frame_equal(df[mask_b], df.loc[0:0, :]) |
1020 |
| - assert_frame_equal(df[-mask_b], df.loc[1:1, :]) |
1021 |
| - |
1022 |
| - def test_float_none_comparison(self): |
1023 |
| - df = DataFrame(np.random.randn(8, 3), index=lrange(8), |
1024 |
| - columns=['A', 'B', 'C']) |
1025 |
| - |
1026 |
| - pytest.raises(TypeError, df.__eq__, None) |
1027 |
| - |
1028 | 949 | def test_boolean_comparison(self):
|
1029 | 950 |
|
1030 | 951 | # GH 4576
|
@@ -1091,16 +1012,6 @@ def test_boolean_comparison(self):
|
1091 | 1012 | result = df == tup
|
1092 | 1013 | assert_frame_equal(result, expected)
|
1093 | 1014 |
|
1094 |
| - def test_boolean_comparison_error(self): |
1095 |
| - |
1096 |
| - # GH 4576 |
1097 |
| - # boolean comparisons with a tuple/list give unexpected results |
1098 |
| - df = DataFrame(np.arange(6).reshape((3, 2))) |
1099 |
| - |
1100 |
| - # not shape compatible |
1101 |
| - pytest.raises(ValueError, lambda: df == (2, 2)) |
1102 |
| - pytest.raises(ValueError, lambda: df == [2, 2]) |
1103 |
| - |
1104 | 1015 | def test_combine_generic(self):
|
1105 | 1016 | df1 = self.frame
|
1106 | 1017 | df2 = self.frame.loc[self.frame.index[:-5], ['A', 'B', 'C']]
|
|
0 commit comments