diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index 5327e3fcbea76..66bbc1f1a649b 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -340,7 +340,7 @@ def test_corr_cov_independent_index_column(self): assert result.index.equals(result.columns) def test_corr_invalid_method(self): - # GH PR #22298 + # GH 22298 df = pd.DataFrame(np.random.normal(size=(10, 2))) msg = ("method must be either 'pearson', 'spearman', " "or 'kendall'") @@ -548,8 +548,8 @@ def test_describe_categorical(self): cat = Series(Categorical(["a", "b", "c", "c"])) df3 = DataFrame({"cat": cat, "s": ["a", "b", "c", "c"]}) - res = df3.describe() - tm.assert_numpy_array_equal(res["cat"].values, res["s"].values) + result = df3.describe() + tm.assert_numpy_array_equal(result["cat"].values, result["s"].values) def test_describe_categorical_columns(self): # GH 11558 @@ -620,8 +620,8 @@ def test_describe_timedelta_values(self): index=['count', 'mean', 'std', 'min', '25%', '50%', '75%', 'max']) - res = df.describe() - tm.assert_frame_equal(res, expected) + result = df.describe() + tm.assert_frame_equal(result, expected) exp_repr = (" t1 t2\n" "count 5 5\n" @@ -632,7 +632,7 @@ def test_describe_timedelta_values(self): "50% 3 days 00:00:00 0 days 03:00:00\n" "75% 4 days 00:00:00 0 days 04:00:00\n" "max 5 days 00:00:00 0 days 05:00:00") - assert repr(res) == exp_repr + assert repr(result) == exp_repr def test_describe_tz_values(self, tz_naive_fixture): # GH 21332 @@ -653,8 +653,8 @@ def test_describe_tz_values(self, tz_naive_fixture): 'last', 'mean', 'std', 'min', '25%', '50%', '75%', 'max'] ) - res = df.describe(include='all') - tm.assert_frame_equal(res, expected) + result = df.describe(include='all') + tm.assert_frame_equal(result, expected) def test_reduce_mixed_frame(self): # GH 6806 @@ -684,7 +684,7 @@ def test_count(self, float_frame_with_na, float_frame, float_string_frame): ct2 = frame.count(0) assert isinstance(ct2, Series) - # GH #423 + # GH 423 df = DataFrame(index=lrange(10)) result = df.count(1) expected = Series(0, index=df.index) @@ -731,7 +731,7 @@ def test_sum(self, float_frame_with_na, mixed_float_frame, @pytest.mark.parametrize('method', ['sum', 'mean', 'prod', 'var', 'std', 'skew', 'min', 'max']) def test_stat_operators_attempt_obj_array(self, method): - # GH #676 + # GH 676 data = { 'a': [-0.00049987540199591344, -0.0016467257772919831, 0.00067695870775883013], @@ -873,7 +873,7 @@ def test_var_std(self, float_frame_with_na, datetime_frame, float_frame, @pytest.mark.parametrize( "meth", ['sem', 'var', 'std']) def test_numeric_only_flag(self, meth): - # GH #9201 + # GH 9201 df1 = DataFrame(np.random.randn(5, 3), columns=['foo', 'bar', 'baz']) # set one entry to a number in str format df1.loc[0, 'foo'] = '100' @@ -1438,12 +1438,12 @@ def test_any_all_extra(self): (np.any, {'A': pd.Series([1, 2], dtype='category')}, True), # # Mix - # GH-21484 + # GH 21484 # (np.all, {'A': pd.Series([10, 20], dtype='M8[ns]'), # 'B': pd.Series([10, 20], dtype='m8[ns]')}, True), ]) def test_any_all_np_func(self, func, data, expected): - # https://github.com/pandas-dev/pandas/issues/19976 + # GH 19976 data = DataFrame(data) result = func(data) assert isinstance(result, np.bool_) @@ -1455,7 +1455,7 @@ def test_any_all_np_func(self, func, data, expected): assert result.item() is expected def test_any_all_object(self): - # https://github.com/pandas-dev/pandas/issues/19976 + # GH 19976 result = np.all(DataFrame(columns=['a', 'b'])).item() assert result is True @@ -1477,7 +1477,7 @@ def test_any_all_level_axis_none_raises(self, method): # Isin def test_isin(self): - # GH #4211 + # GH 4211 df = DataFrame({'vals': [1, 2, 3, 4], 'ids': ['a', 'b', 'f', 'n'], 'ids2': ['a', 'n', 'c', 'n']}, index=['foo', 'bar', 'baz', 'qux']) @@ -1489,7 +1489,7 @@ def test_isin(self): @pytest.mark.parametrize("empty", [[], Series(), np.array([])]) def test_isin_empty(self, empty): - # see gh-16991 + # GH 16991 df = DataFrame({'A': ['a', 'b', 'c'], 'B': ['a', 'e', 'f']}) expected = DataFrame(False, df.index, df.columns) @@ -1515,7 +1515,7 @@ def test_isin_dict(self): tm.assert_frame_equal(result, expected) def test_isin_with_string_scalar(self): - # GH4763 + # GH 4763 df = DataFrame({'vals': [1, 2, 3, 4], 'ids': ['a', 'b', 'f', 'n'], 'ids2': ['a', 'n', 'c', 'n']}, index=['foo', 'bar', 'baz', 'qux']) @@ -1541,7 +1541,7 @@ def test_isin_df(self): tm.assert_frame_equal(result, expected) def test_isin_tuples(self): - # GH16394 + # GH 16394 df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'f']}) df['C'] = list(zip(df['A'], df['B'])) result = df['C'].isin([(1, 'a')]) @@ -1751,7 +1751,7 @@ def test_round(self): expected_rounded['col1']) def test_numpy_round(self): - # See gh-12600 + # GH 12600 df = DataFrame([[1.53, 1.36], [0.06, 7.01]]) out = np.round(df, decimals=0) expected = DataFrame([[2., 1.], [0., 7.]]) @@ -1762,7 +1762,7 @@ def test_numpy_round(self): np.round(df, decimals=0, out=df) def test_round_mixed_type(self): - # GH11885 + # GH 11885 df = DataFrame({'col1': [1.1, 2.2, 3.3, 4.4], 'col2': ['1', 'a', 'c', 'f'], 'col3': date_range('20111111', periods=4)}) @@ -1777,7 +1777,7 @@ def test_round_mixed_type(self): tm.assert_frame_equal(df.round({'col3': 1}), df) def test_round_issue(self): - # GH11611 + # GH 11611 df = pd.DataFrame(np.random.random([3, 3]), columns=['A', 'B', 'C'], index=['first', 'second', 'third']) @@ -1794,7 +1794,7 @@ def test_built_in_round(self): pytest.skip("build in round cannot be overridden " "prior to Python 3") - # GH11763 + # GH 11763 # Here's the test frame we'll be working with df = DataFrame( {'col1': [1.123, 2.123, 3.123], 'col2': [1.234, 2.234, 3.234]}) @@ -1838,7 +1838,7 @@ def test_clip(self, float_frame): assert (float_frame.values == original.values).all() def test_inplace_clip(self, float_frame): - # GH #15388 + # GH 15388 median = float_frame.median().median() frame_copy = float_frame.copy() @@ -1854,7 +1854,7 @@ def test_inplace_clip(self, float_frame): assert not (frame_copy.values != median).any() def test_dataframe_clip(self): - # GH #2747 + # GH 2747 df = DataFrame(np.random.randn(1000, 2)) for lb, ub in [(-1, 1), (1, -1)]: @@ -1881,7 +1881,7 @@ def test_clip_mixed_numeric(self): @pytest.mark.parametrize("inplace", [True, False]) def test_clip_against_series(self, inplace): - # GH #6966 + # GH 6966 df = DataFrame(np.random.randn(1000, 2)) lb = Series(np.random.randn(1000)) @@ -1916,7 +1916,7 @@ def test_clip_against_series(self, inplace): ]) def test_clip_against_list_like(self, simple_frame, inplace, lower, axis, res): - # GH #15390 + # GH 15390 original = simple_frame.copy(deep=True) result = original.clip(lower=lower, upper=[5, 6, 7], @@ -1947,12 +1947,12 @@ def test_clip_against_frame(self, axis): def test_clip_with_na_args(self, float_frame): """Should process np.nan argument as None """ - # GH # 17276 + # GH 17276 tm.assert_frame_equal(float_frame.clip(np.nan), float_frame) tm.assert_frame_equal(float_frame.clip(upper=np.nan, lower=np.nan), float_frame) - # GH #19992 + # GH 19992 df = DataFrame({'col_0': [1, 2, 3], 'col_1': [4, 5, 6], 'col_2': [7, 8, 9]}) @@ -2025,7 +2025,7 @@ def test_dot(self): _np_version_under1p12, reason="unpredictable return types under numpy < 1.12") def test_matmul(self): - # matmul test is for GH #10259 + # matmul test is for GH 10259 a = DataFrame(np.random.randn(3, 4), index=['a', 'b', 'c'], columns=['p', 'q', 'r', 's']) b = DataFrame(np.random.randn(4, 2), index=['p', 'q', 'r', 's'], @@ -2139,7 +2139,7 @@ class TestNLargestNSmallest(object): ['b', 'c', 'c']]) @pytest.mark.parametrize('n', range(1, 11)) def test_n(self, df_strings, nselect_method, n, order): - # GH10393 + # GH 10393 df = df_strings if 'b' in order: @@ -2190,7 +2190,7 @@ def test_duplicates_on_starter_columns(self, method, expected): tm.assert_frame_equal(result, expected) def test_n_identical_values(self): - # GH15297 + # GH 15297 df = pd.DataFrame({'a': [1] * 5, 'b': [1, 2, 3, 4, 5]}) result = df.nlargest(3, 'a') @@ -2224,7 +2224,7 @@ def test_n_duplicate_index(self, df_duplicates, n, order): tm.assert_frame_equal(result, expected) def test_duplicate_keep_all_ties(self): - # see gh-16818 + # GH 16818 df = pd.DataFrame({'a': [5, 4, 4, 2, 3, 3, 3, 3], 'b': [10, 9, 8, 7, 5, 50, 10, 20]}) result = df.nlargest(4, 'a', keep='all') diff --git a/pandas/tests/frame/test_api.py b/pandas/tests/frame/test_api.py index 35f2f566ef85e..4b4296e4abc16 100644 --- a/pandas/tests/frame/test_api.py +++ b/pandas/tests/frame/test_api.py @@ -192,7 +192,7 @@ def test_iteritems(self): assert isinstance(v, self.klass._constructor_sliced) def test_items(self): - # issue #17213, #13918 + # GH 17213, GH 13918 cols = ['a', 'b', 'c'] df = DataFrame([[1, 2, 3], [4, 5, 6]], columns=cols) for c, (k, v) in zip(cols, df.items()): @@ -213,7 +213,7 @@ def test_iterrows(self, float_frame, float_string_frame): self._assert_series_equal(v, exp) def test_iterrows_iso8601(self): - # GH19671 + # GH 19671 if self.klass == SparseDataFrame: pytest.xfail(reason='SparseBlock datetime type not implemented.') @@ -354,7 +354,7 @@ def test_axis_aliases(self, float_frame): assert_series_equal(result, expected) def test_class_axis(self): - # https://github.com/pandas-dev/pandas/issues/18147 + # GH 18147 # no exception and no empty docstring assert pydoc.getdoc(DataFrame.index) assert pydoc.getdoc(DataFrame.columns) @@ -366,9 +366,9 @@ def test_more_values(self, float_string_frame): def test_repr_with_mi_nat(self, float_string_frame): df = self.klass({'X': [1, 2]}, index=[[pd.NaT, pd.Timestamp('20130101')], ['a', 'b']]) - res = repr(df) - exp = ' X\nNaT a 1\n2013-01-01 b 2' - assert res == exp + result = repr(df) + expected = ' X\nNaT a 1\n2013-01-01 b 2' + assert result == expected def test_iteritems_names(self, float_string_frame): for k, v in compat.iteritems(float_string_frame): @@ -418,7 +418,7 @@ def test_values(self, float_frame): assert (float_frame.values[:, 0] == 5).all() def test_as_matrix_deprecated(self, float_frame): - # GH18458 + # GH 18458 with tm.assert_produces_warning(FutureWarning): cols = float_frame.columns.tolist() result = float_frame.as_matrix(columns=cols) @@ -439,7 +439,7 @@ def test_transpose_get_view(self, float_frame): assert (float_frame.values[5:10] == 5).all() def test_inplace_return_self(self): - # re #1893 + # GH 1893 data = DataFrame({'a': ['foo', 'bar', 'baz', 'qux'], 'b': [0, 0, 1, 1], @@ -503,7 +503,7 @@ def _check_f(base, f): _check_f(d.copy(), f) def test_tab_complete_warning(self, ip): - # https://github.com/pandas-dev/pandas/issues/16409 + # GH 16409 pytest.importorskip('IPython', minversion="6.0.0") from IPython.core.completer import provisionalcompleter diff --git a/pandas/tests/frame/test_apply.py b/pandas/tests/frame/test_apply.py index e27115cfc255b..ca3469f34fee6 100644 --- a/pandas/tests/frame/test_apply.py +++ b/pandas/tests/frame/test_apply.py @@ -59,7 +59,7 @@ def test_apply(self, float_frame): [[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=['a', 'a', 'c']) pytest.raises(ValueError, df.apply, lambda x: x, 2) - # see gh-9573 + # GH 9573 df = DataFrame({'c0': ['A', 'A', 'B', 'B'], 'c1': ['C', 'C', 'D', 'D']}) df = df.apply(lambda ts: ts.astype('category')) @@ -94,10 +94,10 @@ def test_apply_empty(self, float_frame, empty_frame): expected = Series(np.nan, index=float_frame.index) assert_series_equal(result, expected) - # 2476 - xp = DataFrame(index=['a']) - rs = xp.apply(lambda x: x['a'], axis=1) - assert_frame_equal(xp, rs) + # GH 2476 + expected = DataFrame(index=['a']) + result = expected.apply(lambda x: x['a'], axis=1) + assert_frame_equal(expected, result) def test_apply_with_reduce_empty(self, empty_frame): # reduce with an empty DataFrame @@ -126,12 +126,13 @@ def test_apply_deprecate_reduce(self, empty_frame): def test_apply_standard_nonunique(self): df = DataFrame( [[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=['a', 'a', 'c']) - rs = df.apply(lambda s: s[0], axis=1) - xp = Series([1, 4, 7], ['a', 'a', 'c']) - assert_series_equal(rs, xp) - rs = df.T.apply(lambda s: s[0], axis=0) - assert_series_equal(rs, xp) + result = df.apply(lambda s: s[0], axis=1) + expected = Series([1, 4, 7], ['a', 'a', 'c']) + assert_series_equal(result, expected) + + result = df.T.apply(lambda s: s[0], axis=0) + assert_series_equal(result, expected) @pytest.mark.parametrize('func', ['sum', 'mean', 'min', 'max', 'std']) @pytest.mark.parametrize('args,kwds', [ @@ -265,13 +266,13 @@ def _check(df, f): is_reduction = not isinstance(test_res, np.ndarray) def _checkit(axis=0, raw=False): - res = df.apply(f, axis=axis, raw=raw) + result = df.apply(f, axis=axis, raw=raw) if is_reduction: agg_axis = df._get_agg_axis(axis) - assert isinstance(res, Series) - assert res.index is agg_axis + assert isinstance(result, Series) + assert result.index is agg_axis else: - assert isinstance(res, DataFrame) + assert isinstance(result, DataFrame) _checkit() _checkit(axis=1) @@ -298,16 +299,16 @@ def subtract_and_divide(x, sub, divide=1): return (x - sub) / divide result = float_frame.apply(add_some, howmuch=2) - exp = float_frame.apply(lambda x: x + 2) - assert_frame_equal(result, exp) + expected = float_frame.apply(lambda x: x + 2) + assert_frame_equal(result, expected) result = float_frame.apply(agg_and_add, howmuch=2) - exp = float_frame.apply(lambda x: x.mean() + 2) - assert_series_equal(result, exp) + expected = float_frame.apply(lambda x: x.mean() + 2) + assert_series_equal(result, expected) - res = float_frame.apply(subtract_and_divide, args=(2,), divide=2) - exp = float_frame.apply(lambda x: (x - 2.) / 2.) - assert_frame_equal(res, exp) + result = float_frame.apply(subtract_and_divide, args=(2,), divide=2) + expected = float_frame.apply(lambda x: (x - 2.) / 2.) + assert_frame_equal(result, expected) def test_apply_yield_list(self, float_frame): result = float_frame.apply(list) @@ -467,11 +468,11 @@ def test_applymap(self, float_frame): tm.assert_frame_equal(applied, float_frame * 2) float_frame.applymap(type) - # gh-465: function returning tuples + # GH 465: function returning tuples result = float_frame.applymap(lambda x: (x, x)) assert isinstance(result['A'][0], tuple) - # gh-2909: object conversion to float in constructor? + # GH 2909: object conversion to float in constructor? df = DataFrame(data=[1, 'a']) result = df.applymap(lambda x: x) assert result.dtypes[0] == object @@ -480,7 +481,7 @@ def test_applymap(self, float_frame): result = df.applymap(lambda x: x) assert result.dtypes[0] == object - # see gh-2786 + # GH 2786 df = DataFrame(np.random.random((3, 4))) df2 = df.copy() cols = ['a', 'a', 'a', 'a'] @@ -498,7 +499,7 @@ def test_applymap(self, float_frame): for f in ['datetime', 'timedelta']: assert result.loc[0, f] == str(df.loc[0, f]) - # see gh-8222 + # GH 8222 empty_frames = [pd.DataFrame(), pd.DataFrame(columns=list('ABC')), pd.DataFrame(index=list('ABC')), @@ -509,7 +510,7 @@ def test_applymap(self, float_frame): tm.assert_frame_equal(result, frame) def test_applymap_box_timestamps(self): - # #2689, #2627 + # GH 2689, GH 2627 ser = pd.Series(date_range('1/1/2000', periods=10)) def func(x): @@ -529,12 +530,12 @@ def test_applymap_box(self): 'd': [pd.Period('2011-01-01', freq='M'), pd.Period('2011-01-02', freq='M')]}) - res = df.applymap(lambda x: '{0}'.format(x.__class__.__name__)) - exp = pd.DataFrame({'a': ['Timestamp', 'Timestamp'], - 'b': ['Timestamp', 'Timestamp'], - 'c': ['Timedelta', 'Timedelta'], - 'd': ['Period', 'Period']}) - tm.assert_frame_equal(res, exp) + result = df.applymap(lambda x: '{0}'.format(x.__class__.__name__)) + expected = pd.DataFrame({'a': ['Timestamp', 'Timestamp'], + 'b': ['Timestamp', 'Timestamp'], + 'c': ['Timedelta', 'Timedelta'], + 'd': ['Period', 'Period']}) + tm.assert_frame_equal(result, expected) def test_frame_apply_dont_convert_datetime64(self): from pandas.tseries.offsets import BDay @@ -546,7 +547,7 @@ def test_frame_apply_dont_convert_datetime64(self): assert df.x1.dtype == 'M8[ns]' def test_apply_non_numpy_dtype(self): - # See gh-12244 + # GH 12244 df = DataFrame({'dt': pd.date_range( "2015-01-01", periods=3, tz='Europe/Brussels')}) result = df.apply(lambda x: x) @@ -576,7 +577,7 @@ class TestInferOutputShape(object): # us to infer the output def test_infer_row_shape(self): - # gh-17437 + # GH 17437 # if row shape is changing, infer it df = pd.DataFrame(np.random.rand(10, 2)) result = df.apply(np.fft.fft, axis=0) @@ -586,7 +587,7 @@ def test_infer_row_shape(self): assert result.shape == (6, 2) def test_with_dictlike_columns(self): - # gh 17602 + # GH 17602 df = DataFrame([[1, 2], [1, 2]], columns=['a', 'b']) result = df.apply(lambda x: {'s': x['a'] + x['b']}, axis=1) @@ -604,7 +605,7 @@ def test_with_dictlike_columns(self): expected = Series([{'s': 3}, {'s': 3}]) assert_series_equal(result, expected) - # gh-18775 + # GH 18775 df = DataFrame() df["author"] = ["X", "Y", "Z"] df["publisher"] = ["BBC", "NBC", "N24"] @@ -616,7 +617,7 @@ def test_with_dictlike_columns(self): assert_series_equal(result, expected) def test_with_dictlike_columns_with_infer(self): - # gh 17602 + # GH 17602 df = DataFrame([[1, 2], [1, 2]], columns=['a', 'b']) result = df.apply(lambda x: {'s': x['a'] + x['b']}, axis=1, result_type='expand') @@ -630,7 +631,7 @@ def test_with_dictlike_columns_with_infer(self): assert_frame_equal(result, expected) def test_with_listlike_columns(self): - # gh-17348 + # GH 17348 df = DataFrame({'a': Series(np.random.randn(4)), 'b': ['a', 'list', 'of', 'words'], 'ts': date_range('2016-10-01', periods=4, freq='H')}) @@ -643,7 +644,7 @@ def test_with_listlike_columns(self): expected = Series([t[1:] for t in df[['a', 'ts']].itertuples()]) assert_series_equal(result, expected) - # gh-18919 + # GH 18919 df = DataFrame({'x': Series([['a', 'b'], ['q']]), 'y': Series([['z'], ['q', 't']])}) df.index = MultiIndex.from_tuples([('i0', 'j0'), ('i1', 'j1')]) @@ -655,7 +656,7 @@ def test_with_listlike_columns(self): assert_series_equal(result, expected) def test_infer_output_shape_columns(self): - # gh-18573 + # GH 18573 df = DataFrame({'number': [1., 2.], 'string': ['foo', 'bar'], @@ -666,7 +667,7 @@ def test_infer_output_shape_columns(self): assert_series_equal(result, expected) def test_infer_output_shape_listlike_columns(self): - # gh-16353 + # GH 16353 df = DataFrame(np.random.randn(6, 3), columns=['A', 'B', 'C']) @@ -678,7 +679,7 @@ def test_infer_output_shape_listlike_columns(self): expected = Series([[1, 2] for t in df.itertuples()]) assert_series_equal(result, expected) - # gh-17970 + # GH 17970 df = DataFrame({"a": [1, 2, 3]}, index=list('abc')) result = df.apply(lambda row: np.ones(1), axis=1) @@ -691,7 +692,7 @@ def test_infer_output_shape_listlike_columns(self): index=df.index) assert_series_equal(result, expected) - # gh-17892 + # GH 17892 df = pd.DataFrame({'a': [pd.Timestamp('2010-02-01'), pd.Timestamp('2010-02-04'), pd.Timestamp('2010-02-05'), @@ -899,7 +900,7 @@ def f(): 'abs', 'shift', 'pct_change', 'cumsum', 'rank', ]) def test_transform_method_name(self, method): - # https://github.com/pandas-dev/pandas/issues/19760 + # GH 19760 df = pd.DataFrame({"A": [-1, 2]}) result = df.transform(method) expected = operator.methodcaller(method)(df) @@ -923,7 +924,7 @@ def test_demo(self): tm.assert_frame_equal(result.reindex_like(expected), expected) def test_agg_multiple_mixed_no_warning(self): - # https://github.com/pandas-dev/pandas/issues/20909 + # GH 20909 mdf = pd.DataFrame({'A': [1, 2, 3], 'B': [1., 2., 3.], 'C': ['foo', 'bar', 'baz'], @@ -1106,7 +1107,7 @@ def test_non_callable_aggregates(self): ]), )) def test_agg_cython_table(self, df, func, expected, axis): - # GH21224 + # GH 21224 # test reducing functions in # pandas.core.base.SelectionMixin._cython_table result = df.agg(func, axis=axis) @@ -1125,7 +1126,7 @@ def test_agg_cython_table(self, df, func, expected, axis): ]), )) def test_agg_cython_table_transform(self, df, func, expected, axis): - # GH21224 + # GH 21224 # test transforming functions in # pandas.core.base.SelectionMixin._cython_table (cumprod, cumsum) result = df.agg(func, axis=axis) @@ -1137,7 +1138,7 @@ def test_agg_cython_table_transform(self, df, func, expected, axis): ]), ) def test_agg_cython_table_raises(self, df, func, expected, axis): - # GH21224 + # GH 21224 with pytest.raises(expected): df.agg(func, axis=axis) @@ -1156,7 +1157,7 @@ def indices(draw, max_length=5): @given(index=indices(5), num_columns=integers(0, 5)) def test_frequency_is_original(self, index, num_columns): - # GH22150 + # GH 22150 original = index.copy() df = DataFrame(True, index=index, columns=range(num_columns)) df.apply(lambda x: x) diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index b97c5e4f7d7c2..d0eb7cd35b268 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -17,7 +17,7 @@ class TestFrameComparisons(object): def test_flex_comparison_nat(self): - # GH#15697, GH#22163 df.eq(pd.NaT) should behave like df == pd.NaT, + # GH 15697, GH 22163 df.eq(pd.NaT) should behave like df == pd.NaT, # and _definitely_ not be NaN df = pd.DataFrame([pd.NaT]) @@ -35,7 +35,7 @@ def test_flex_comparison_nat(self): assert result.iloc[0, 0].item() is True def test_mixed_comparison(self): - # GH#13128, GH#22163 != datetime64 vs non-dt64 should be False, + # GH 13128, GH 22163 != datetime64 vs non-dt64 should be False, # not raise TypeError # (this appears to be fixed before #22163, not sure when) df = pd.DataFrame([['1989-08-01', 1], ['1989-08-01', 2]]) @@ -48,7 +48,7 @@ def test_mixed_comparison(self): assert result.all().all() def test_df_boolean_comparison_error(self): - # GH#4576 + # GH 4576 # boolean comparisons with a tuple/list give unexpected results df = pd.DataFrame(np.arange(6).reshape((3, 2))) @@ -77,7 +77,7 @@ def test_df_string_comparison(self): @pytest.mark.parametrize('opname', ['eq', 'ne', 'gt', 'lt', 'ge', 'le']) def test_df_flex_cmp_constant_return_types(self, opname): - # GH#15077, non-empty DataFrame + # GH 15077, non-empty DataFrame df = pd.DataFrame({'x': [1, 2, 3], 'y': [1., 2., 3.]}) const = 2 @@ -86,7 +86,7 @@ def test_df_flex_cmp_constant_return_types(self, opname): @pytest.mark.parametrize('opname', ['eq', 'ne', 'gt', 'lt', 'ge', 'le']) def test_df_flex_cmp_constant_return_types_empty(self, opname): - # GH#15077 empty DataFrame + # GH 15077 empty DataFrame df = pd.DataFrame({'x': [1, 2, 3], 'y': [1., 2., 3.]}) const = 2 @@ -101,7 +101,7 @@ def test_df_flex_cmp_constant_return_types_empty(self, opname): class TestFrameFlexArithmetic(object): def test_df_add_td64_columnwise(self): - # GH#22534 Check that column-wise addition broadcasts correctly + # GH 22534 Check that column-wise addition broadcasts correctly dti = pd.date_range('2016-01-01', periods=10) tdi = pd.timedelta_range('1', periods=10) tser = pd.Series(tdi) @@ -113,7 +113,7 @@ def test_df_add_td64_columnwise(self): tm.assert_frame_equal(result, expected) def test_df_add_flex_filled_mixed_dtypes(self): - # GH#19611 + # GH 19611 dti = pd.date_range('2016-01-01', periods=3) ser = pd.Series(['1 Day', 'NaT', '2 Days'], dtype='timedelta64[ns]') df = pd.DataFrame({'A': dti, 'B': ser}) @@ -139,13 +139,13 @@ def f(x, y): return getattr(operator, op)(x, y) result = getattr(float_frame, op)(2 * float_frame) - exp = f(float_frame, 2 * float_frame) - tm.assert_frame_equal(result, exp) + expected = f(float_frame, 2 * float_frame) + tm.assert_frame_equal(result, expected) # vs mix float result = getattr(mixed_float_frame, op)(2 * mixed_float_frame) - exp = f(mixed_float_frame, 2 * mixed_float_frame) - tm.assert_frame_equal(result, exp) + expected = f(mixed_float_frame, 2 * mixed_float_frame) + tm.assert_frame_equal(result, expected) _check_mixed_float(result, dtype=dict(C=None)) @pytest.mark.parametrize('op', ['__add__', '__sub__', '__mul__']) @@ -155,7 +155,7 @@ def test_arith_flex_frame_mixed(self, op, int_frame, mixed_int_frame, # vs mix int result = getattr(mixed_int_frame, op)(2 + mixed_int_frame) - exp = f(mixed_int_frame, 2 + mixed_int_frame) + expected = f(mixed_int_frame, 2 + mixed_int_frame) # no overflow in the uint dtype = None @@ -163,19 +163,19 @@ def test_arith_flex_frame_mixed(self, op, int_frame, mixed_int_frame, dtype = dict(B='uint64', C=None) elif op in ['__add__', '__mul__']: dtype = dict(C=None) - tm.assert_frame_equal(result, exp) + tm.assert_frame_equal(result, expected) _check_mixed_int(result, dtype=dtype) # vs mix float result = getattr(mixed_float_frame, op)(2 * mixed_float_frame) - exp = f(mixed_float_frame, 2 * mixed_float_frame) - tm.assert_frame_equal(result, exp) + expected = f(mixed_float_frame, 2 * mixed_float_frame) + tm.assert_frame_equal(result, expected) _check_mixed_float(result, dtype=dict(C=None)) # vs plain int result = getattr(int_frame, op)(2 * int_frame) - exp = f(int_frame, 2 * int_frame) - tm.assert_frame_equal(result, exp) + expected = f(int_frame, 2 * int_frame) + tm.assert_frame_equal(result, expected) def test_arith_flex_frame_raise(self, all_arithmetic_operators, float_frame): @@ -227,7 +227,7 @@ def test_arith_flex_series(self, simple_frame): tm.assert_frame_equal(df.div(row), df / row) tm.assert_frame_equal(df.div(col, axis=0), (df.T / col).T) - # broadcasting issue in GH#7325 + # broadcasting issue in GH 7325 df = pd.DataFrame(np.arange(3 * 2).reshape((3, 2)), dtype='int64') expected = pd.DataFrame([[np.nan, np.inf], [1.0, 1.5], [1.0, 1.25]]) result = df.div(df[0], axis='index') @@ -239,7 +239,7 @@ def test_arith_flex_series(self, simple_frame): tm.assert_frame_equal(result, expected) def test_arith_flex_zero_len_raises(self): - # GH#19522 passing fill_value to frame flex arith methods should + # GH 19522 passing fill_value to frame flex arith methods should # raise even in the zero-length special cases ser_len0 = pd.Series([]) df_len0 = pd.DataFrame([], columns=['A', 'B']) @@ -347,7 +347,7 @@ def test_df_arith_2d_array_collike_broadcasts(self, tm.assert_frame_equal(result, expected) def test_df_bool_mul_int(self): - # GH#22047, GH#22163 multiplication by 1 should result in int dtype, + # GH 22047, GH 22163 multiplication by 1 should result in int dtype, # not object dtype df = pd.DataFrame([[False, True], [False, False]]) result = df * 1