diff --git a/pandas/tests/frame/indexing/test_indexing.py b/pandas/tests/frame/indexing/test_indexing.py index 2d58a4391c80c..9370f97f8310b 100644 --- a/pandas/tests/frame/indexing/test_indexing.py +++ b/pandas/tests/frame/indexing/test_indexing.py @@ -439,8 +439,8 @@ def test_setitem_corner(self, float_frame): dm["foo"] = "bar" assert dm["foo"].dtype == np.object_ - dm["coercable"] = ["1", "2", "3"] - assert dm["coercable"].dtype == np.object_ + dm["coercible"] = ["1", "2", "3"] + assert dm["coercible"].dtype == np.object_ def test_setitem_corner2(self): data = { diff --git a/pandas/tests/frame/indexing/test_setitem.py b/pandas/tests/frame/indexing/test_setitem.py index 9d61be5887b7e..10f103343a8b4 100644 --- a/pandas/tests/frame/indexing/test_setitem.py +++ b/pandas/tests/frame/indexing/test_setitem.py @@ -420,7 +420,7 @@ def test_setitem_intervals(self): assert isinstance(ser.cat.categories, IntervalIndex) # B & D end up as Categoricals - # the remainer are converted to in-line objects + # the remainder are converted to in-line objects # containing an IntervalIndex.values df["B"] = ser df["C"] = np.array(ser) @@ -433,13 +433,13 @@ def test_setitem_intervals(self): assert is_categorical_dtype(df["D"].dtype) assert is_interval_dtype(df["D"].cat.categories) - # Thes goes through the Series constructor and so get inferred back + # These go through the Series constructor and so get inferred back # to IntervalDtype assert is_interval_dtype(df["C"]) assert is_interval_dtype(df["E"]) # But the Series constructor doesn't do inference on Series objects, - # so setting df["F"] doesnt get cast back to IntervalDtype + # so setting df["F"] doesn't get cast back to IntervalDtype assert is_object_dtype(df["F"]) # they compare equal as Index diff --git a/pandas/tests/frame/methods/test_cov_corr.py b/pandas/tests/frame/methods/test_cov_corr.py index 33b98fc5c2135..3da3d82ec77f9 100644 --- a/pandas/tests/frame/methods/test_cov_corr.py +++ b/pandas/tests/frame/methods/test_cov_corr.py @@ -207,7 +207,7 @@ def test_corr_item_cache(self, using_array_manager): _ = df.corr() - # Check that the corr didnt break link between ser and df + # Check that the corr didn't break link between ser and df ser.values[0] = 99 assert df.loc[0, "A"] == 99 assert df["A"] is ser diff --git a/pandas/tests/frame/methods/test_quantile.py b/pandas/tests/frame/methods/test_quantile.py index 9d56bb6314534..bc1d4605e985a 100644 --- a/pandas/tests/frame/methods/test_quantile.py +++ b/pandas/tests/frame/methods/test_quantile.py @@ -550,11 +550,11 @@ class TestQuantileExtensionDtype: pd.date_range("2016-01-01", periods=9, tz="US/Pacific"), pytest.param( pd.array(np.arange(9), dtype="Int64"), - marks=pytest.mark.xfail(reason="doesnt implement from_factorized"), + marks=pytest.mark.xfail(reason="doesn't implement from_factorized"), ), pytest.param( pd.array(np.arange(9), dtype="Float64"), - marks=pytest.mark.xfail(reason="doesnt implement from_factorized"), + marks=pytest.mark.xfail(reason="doesn't implement from_factorized"), ), ], ids=lambda x: str(x.dtype), diff --git a/pandas/tests/frame/methods/test_replace.py b/pandas/tests/frame/methods/test_replace.py index 6d1e90e2f9646..56750da7c90b2 100644 --- a/pandas/tests/frame/methods/test_replace.py +++ b/pandas/tests/frame/methods/test_replace.py @@ -1439,8 +1439,8 @@ def test_categorical_replace_with_dict(self, replace_dict, final_data): a = pd.Categorical(final_data[:, 0], categories=[3, 2]) - excat = [3, 2] if replace_dict["b"] == 1 else [1, 3] - b = pd.Categorical(final_data[:, 1], categories=excat) + ex_cat = [3, 2] if replace_dict["b"] == 1 else [1, 3] + b = pd.Categorical(final_data[:, 1], categories=ex_cat) expected = DataFrame({"a": a, "b": b}) result = df.replace(replace_dict, 3) diff --git a/pandas/tests/frame/methods/test_reset_index.py b/pandas/tests/frame/methods/test_reset_index.py index 1374a3503ee11..924059f634fca 100644 --- a/pandas/tests/frame/methods/test_reset_index.py +++ b/pandas/tests/frame/methods/test_reset_index.py @@ -137,8 +137,8 @@ def test_reset_index(self, float_frame): # preserve column names float_frame.columns.name = "columns" - resetted = float_frame.reset_index() - assert resetted.columns.name == "columns" + reset = float_frame.reset_index() + assert reset.columns.name == "columns" # only remove certain columns df = float_frame.reset_index().set_index(["index", "A", "B"]) @@ -159,10 +159,10 @@ def test_reset_index(self, float_frame): # test resetting in place df = float_frame.copy() - resetted = float_frame.reset_index() + reset = float_frame.reset_index() return_value = df.reset_index(inplace=True) assert return_value is None - tm.assert_frame_equal(df, resetted, check_names=False) + tm.assert_frame_equal(df, reset, check_names=False) df = float_frame.reset_index().set_index(["index", "A", "B"]) rs = df.reset_index("A", drop=True) @@ -224,11 +224,11 @@ def test_reset_index_right_dtype(self): ) df = DataFrame(s1) - resetted = s1.reset_index() - assert resetted["time"].dtype == np.float64 + reset = s1.reset_index() + assert reset["time"].dtype == np.float64 - resetted = df.reset_index() - assert resetted["time"].dtype == np.float64 + reset = df.reset_index() + assert reset["time"].dtype == np.float64 def test_reset_index_multiindex_col(self): vals = np.random.randn(3, 3).astype(object) diff --git a/pandas/tests/frame/methods/test_to_dict_of_blocks.py b/pandas/tests/frame/methods/test_to_dict_of_blocks.py index 8b5f45465cb3c..ca222180322bf 100644 --- a/pandas/tests/frame/methods/test_to_dict_of_blocks.py +++ b/pandas/tests/frame/methods/test_to_dict_of_blocks.py @@ -53,7 +53,7 @@ def test_to_dict_of_blocks_item_cache(): df._to_dict_of_blocks() - # Check that the to_dict_of_blocks didnt break link between ser and df + # Check that the to_dict_of_blocks didn't break link between ser and df ser.values[0] = "foo" assert df.loc[0, "b"] == "foo" diff --git a/pandas/tests/frame/methods/test_values.py b/pandas/tests/frame/methods/test_values.py index 38e58860959b8..548482b23ebc4 100644 --- a/pandas/tests/frame/methods/test_values.py +++ b/pandas/tests/frame/methods/test_values.py @@ -91,7 +91,7 @@ def test_frame_values_with_tz(self): ) tm.assert_numpy_array_equal(result, expected) - # two columns, homogenous + # two columns, homogeneous df["B"] = df["A"] result = df.values diff --git a/pandas/tests/frame/test_subclass.py b/pandas/tests/frame/test_subclass.py index 784ca03fa9c03..6be91c9e75188 100644 --- a/pandas/tests/frame/test_subclass.py +++ b/pandas/tests/frame/test_subclass.py @@ -519,7 +519,7 @@ def test_subclassed_apply(self): def check_row_subclass(row): assert isinstance(row, tm.SubclassedSeries) - def strech(row): + def stretch(row): if row["variable"] == "height": row["value"] += 0.5 return row @@ -547,7 +547,7 @@ def strech(row): columns=["first", "last", "variable", "value"], ) - result = df.apply(lambda x: strech(x), axis=1) + result = df.apply(lambda x: stretch(x), axis=1) assert isinstance(result, tm.SubclassedDataFrame) tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/groupby/aggregate/test_aggregate.py b/pandas/tests/groupby/aggregate/test_aggregate.py index b7df1c8382daa..fc0b4d86e81bf 100644 --- a/pandas/tests/groupby/aggregate/test_aggregate.py +++ b/pandas/tests/groupby/aggregate/test_aggregate.py @@ -758,7 +758,7 @@ def test_agg_relabel_multiindex_column( def test_agg_relabel_multiindex_raises_not_exist(): - # GH 29422, add test for raises senario when aggregate column does not exist + # GH 29422, add test for raises scenario when aggregate column does not exist df = DataFrame( {"group": ["a", "a", "b", "b"], "A": [0, 1, 2, 3], "B": [5, 6, 7, 8]} ) @@ -769,7 +769,7 @@ def test_agg_relabel_multiindex_raises_not_exist(): def test_agg_relabel_multiindex_duplicates(): - # GH29422, add test for raises senario when getting duplicates + # GH29422, add test for raises scenario when getting duplicates # GH28426, after this change, duplicates should also work if the relabelling is # different df = DataFrame( diff --git a/pandas/tests/groupby/test_libgroupby.py b/pandas/tests/groupby/test_libgroupby.py index 28b740355f351..30b0edf8a139e 100644 --- a/pandas/tests/groupby/test_libgroupby.py +++ b/pandas/tests/groupby/test_libgroupby.py @@ -176,13 +176,13 @@ def _check_cython_group_transform_cumulative(pd_op, np_op, dtype): is_datetimelike = False data = np.array([[1], [2], [3], [4]], dtype=dtype) - ans = np.zeros_like(data) + answer = np.zeros_like(data) labels = np.array([0, 0, 0, 0], dtype=np.int64) ngroups = 1 - pd_op(ans, data, labels, ngroups, is_datetimelike) + pd_op(answer, data, labels, ngroups, is_datetimelike) - tm.assert_numpy_array_equal(np_op(data), ans[:, 0], check_dtype=False) + tm.assert_numpy_array_equal(np_op(data), answer[:, 0], check_dtype=False) def test_cython_group_transform_cumsum(any_real_dtype): diff --git a/pandas/tests/indexes/categorical/test_formats.py b/pandas/tests/indexes/categorical/test_formats.py index 2009d78e47c1c..98948c2113bbe 100644 --- a/pandas/tests/indexes/categorical/test_formats.py +++ b/pandas/tests/indexes/categorical/test_formats.py @@ -76,7 +76,7 @@ def test_string_categorical_index_repr(self): assert repr(idx) == expected - # Emable Unicode option ----------------------------------------- + # Enable Unicode option ----------------------------------------- with cf.option_context("display.unicode.east_asian_width", True): # short diff --git a/pandas/tests/indexes/datetimelike_/test_sort_values.py b/pandas/tests/indexes/datetimelike_/test_sort_values.py index ad9c5ca848615..9a91cc26c1430 100644 --- a/pandas/tests/indexes/datetimelike_/test_sort_values.py +++ b/pandas/tests/indexes/datetimelike_/test_sort_values.py @@ -295,7 +295,7 @@ def test_sort_values_without_freq_periodindex(self, idx, expected): self.check_sort_values_without_freq(idx, expected) def test_sort_values_without_freq_periodindex_nat(self): - # doesnt quite fit into check_sort_values_without_freq + # doesn't quite fit into check_sort_values_without_freq idx = PeriodIndex(["2011", "2013", "NaT", "2011"], name="pidx", freq="D") expected = PeriodIndex(["NaT", "2011", "2011", "2013"], name="pidx", freq="D") diff --git a/pandas/tests/indexes/datetimes/methods/test_insert.py b/pandas/tests/indexes/datetimes/methods/test_insert.py index bf3d5bf88149e..aa9b2c5291585 100644 --- a/pandas/tests/indexes/datetimes/methods/test_insert.py +++ b/pandas/tests/indexes/datetimes/methods/test_insert.py @@ -47,7 +47,7 @@ def test_insert_empty_preserves_freq(self, tz_naive_fixture): result = dti.insert(0, item) assert result.freq == dti.freq - # But not when we insert an item that doesnt conform to freq + # But not when we insert an item that doesn't conform to freq dti = DatetimeIndex([], tz=tz, freq="W-THU") result = dti.insert(0, item) assert result.freq is None diff --git a/pandas/tests/indexes/datetimes/test_timezones.py b/pandas/tests/indexes/datetimes/test_timezones.py index 3ab58471cdbed..bc01d44de0529 100644 --- a/pandas/tests/indexes/datetimes/test_timezones.py +++ b/pandas/tests/indexes/datetimes/test_timezones.py @@ -465,7 +465,7 @@ def test_dti_tz_localize_roundtrip(self, tz_aware_fixture): idx = date_range(start="2014-06-01", end="2014-08-30", freq="15T") tz = tz_aware_fixture localized = idx.tz_localize(tz) - # cant localize a tz-aware object + # can't localize a tz-aware object with pytest.raises( TypeError, match="Already tz-aware, use tz_convert to convert" ): diff --git a/pandas/tests/indexes/multi/test_constructors.py b/pandas/tests/indexes/multi/test_constructors.py index c4b4562fe9e47..79a60c14f5eac 100644 --- a/pandas/tests/indexes/multi/test_constructors.py +++ b/pandas/tests/indexes/multi/test_constructors.py @@ -108,7 +108,7 @@ def test_constructor_mismatched_codes_levels(idx): def test_na_levels(): # GH26408 # test if codes are re-assigned value -1 for levels - # with mising values (NaN, NaT, None) + # with missing values (NaN, NaT, None) result = MultiIndex( levels=[[np.nan, None, pd.NaT, 128, 2]], codes=[[0, -1, 1, 2, 3, 4]] ) diff --git a/pandas/tests/indexes/period/test_indexing.py b/pandas/tests/indexes/period/test_indexing.py index fcf01f850711b..9b7685b23289a 100644 --- a/pandas/tests/indexes/period/test_indexing.py +++ b/pandas/tests/indexes/period/test_indexing.py @@ -464,7 +464,7 @@ def test_get_indexer_mismatched_dtype(self): tm.assert_numpy_array_equal(result, expected) def test_get_indexer_mismatched_dtype_different_length(self, non_comparable_idx): - # without method we arent checking inequalities, so get all-missing + # without method we aren't checking inequalities, so get all-missing # but do not raise dti = date_range("2016-01-01", periods=3) pi = dti.to_period("D") diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index ada4b25d2ed0f..53d3187ee5664 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -386,7 +386,7 @@ def test_constructor_dtypes_datetime(self, tz_naive_fixture, attr, klass): @pytest.mark.parametrize("klass", [Index, TimedeltaIndex]) def test_constructor_dtypes_timedelta(self, attr, klass): index = pd.timedelta_range("1 days", periods=5) - index = index._with_freq(None) # wont be preserved by constructors + index = index._with_freq(None) # won't be preserved by constructors dtype = index.dtype values = getattr(index, attr) diff --git a/pandas/tests/indexes/timedeltas/methods/test_insert.py b/pandas/tests/indexes/timedeltas/methods/test_insert.py index 067031c694810..809d21db805e0 100644 --- a/pandas/tests/indexes/timedeltas/methods/test_insert.py +++ b/pandas/tests/indexes/timedeltas/methods/test_insert.py @@ -128,7 +128,7 @@ def test_insert_non_castable_str(self): tm.assert_index_equal(result, expected) def test_insert_empty(self): - # Corner case inserting with length zero doesnt raise IndexError + # Corner case inserting with length zero doesn't raise IndexError # GH#33573 for freq preservation idx = timedelta_range("1 Day", periods=3) td = idx[0] diff --git a/pandas/tests/indexes/timedeltas/test_setops.py b/pandas/tests/indexes/timedeltas/test_setops.py index 907a3463971ca..bd2303fd7d19f 100644 --- a/pandas/tests/indexes/timedeltas/test_setops.py +++ b/pandas/tests/indexes/timedeltas/test_setops.py @@ -116,7 +116,7 @@ def test_intersection_bug_1708(self): def test_intersection_equal(self, sort): # GH 24471 Test intersection outcome given the sort keyword - # for equal indicies intersection should return the original index + # for equal indices intersection should return the original index first = timedelta_range("1 day", periods=4, freq="h") second = timedelta_range("1 day", periods=4, freq="h") intersect = first.intersection(second, sort=sort) diff --git a/pandas/tests/indexing/common.py b/pandas/tests/indexing/common.py index f70897147c867..f7c2266e39fcc 100644 --- a/pandas/tests/indexing/common.py +++ b/pandas/tests/indexing/common.py @@ -136,9 +136,9 @@ def check_values(self, f, func, values=False): if f is None: return axes = f.axes - indicies = itertools.product(*axes) + indices = itertools.product(*axes) - for i in indicies: + for i in indices: result = getattr(f, func)[i] # check against values diff --git a/pandas/tests/indexing/test_coercion.py b/pandas/tests/indexing/test_coercion.py index 2c962df30f1ff..7642f78076dcb 100644 --- a/pandas/tests/indexing/test_coercion.py +++ b/pandas/tests/indexing/test_coercion.py @@ -443,7 +443,7 @@ def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value assert expected.dtype == object tm.assert_index_equal(result, expected) - # mismatched tz --> cast to object (could reasonably cast to commom tz) + # mismatched tz --> cast to object (could reasonably cast to common tz) ts = pd.Timestamp("2012-01-01", tz="Asia/Tokyo") result = obj.insert(1, ts) expected = obj.astype(object).insert(1, ts) diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index c28674380a839..6a0a6ed18e2e1 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -112,7 +112,7 @@ def test_iloc_setitem_ea_inplace(self, frame_or_series, box): assert obj.values.base is values.base and values.base is not None def test_is_scalar_access(self): - # GH#32085 index with duplicates doesnt matter for _is_scalar_access + # GH#32085 index with duplicates doesn't matter for _is_scalar_access index = Index([1, 2, 1]) ser = Series(range(3), index=index) @@ -739,18 +739,18 @@ def test_iloc_mask(self): accessor = getattr(df, method[1:]) else: accessor = df - ans = str(bin(accessor[mask]["nums"].sum())) + answer = str(bin(accessor[mask]["nums"].sum())) except (ValueError, IndexingError, NotImplementedError) as e: - ans = str(e) + answer = str(e) key = ( idx, method, ) r = expected.get(key) - if r != ans: + if r != answer: raise AssertionError( - f"[{key}] does not match [{ans}], received [{r}]" + f"[{key}] does not match [{answer}], received [{r}]" ) def test_iloc_non_unique_indexing(self):