From af47c16259846636872f37183af88edf129b8a54 Mon Sep 17 00:00:00 2001 From: VirosaLi <2EkF8qUgpNkj> Date: Fri, 27 Nov 2020 10:57:24 -0600 Subject: [PATCH 1/2] CLN: fix some of flake8 C408 part 2 --- pandas/_testing.py | 18 ++--- pandas/compat/numpy/function.py | 16 ++-- pandas/core/arrays/_mixins.py | 2 +- pandas/core/arrays/sparse/array.py | 2 +- pandas/core/arrays/timedeltas.py | 4 +- pandas/core/base.py | 14 ++-- pandas/core/dtypes/generic.py | 4 +- pandas/core/groupby/groupby.py | 10 +-- pandas/core/indexes/category.py | 2 +- pandas/core/indexes/datetimelike.py | 2 +- pandas/core/indexes/datetimes.py | 2 +- pandas/core/indexes/extension.py | 2 +- pandas/core/indexes/period.py | 2 +- pandas/core/internals/managers.py | 2 +- pandas/core/resample.py | 2 +- pandas/core/reshape/melt.py | 2 +- pandas/core/shared_docs.py | 2 +- pandas/core/util/numba_.py | 2 +- pandas/io/formats/csvs.py | 14 ++-- pandas/io/formats/printing.py | 2 +- pandas/io/formats/style.py | 20 ++--- pandas/io/json/_json.py | 2 +- pandas/io/stata.py | 2 +- pandas/tests/arithmetic/test_timedelta64.py | 2 +- .../tests/arrays/categorical/test_missing.py | 8 +- pandas/tests/arrays/sparse/test_libsparse.py | 77 ++++++++++--------- pandas/tests/dtypes/test_common.py | 20 ++--- pandas/tests/extension/base/methods.py | 8 +- pandas/tests/frame/common.py | 4 +- pandas/tests/frame/methods/test_astype.py | 2 +- pandas/tests/frame/methods/test_convert.py | 4 +- pandas/tests/frame/methods/test_diff.py | 8 +- pandas/tests/frame/methods/test_rename.py | 4 +- pandas/tests/frame/methods/test_replace.py | 2 +- .../tests/frame/methods/test_reset_index.py | 2 +- pandas/tests/frame/test_nonunique_indexes.py | 2 +- pandas/tests/frame/test_query_eval.py | 2 +- pandas/tests/frame/test_stack_unstack.py | 28 +++---- pandas/tests/frame/test_ufunc.py | 2 +- pandas/tests/frame/test_validate.py | 2 +- pandas/tests/generic/test_duplicate_labels.py | 6 +- pandas/tests/groupby/test_apply.py | 4 +- pandas/tests/groupby/test_groupby.py | 12 +-- pandas/tests/groupby/test_quantile.py | 4 +- pandas/tests/groupby/test_timegrouper.py | 2 +- pandas/tests/groupby/test_value_counts.py | 10 ++- .../indexes/period/test_partial_slicing.py | 2 +- pandas/tests/io/formats/test_to_excel.py | 4 +- pandas/tests/io/formats/test_to_html.py | 4 +- pandas/tests/io/formats/test_to_latex.py | 2 +- pandas/tests/io/json/test_pandas.py | 18 ++--- pandas/tests/io/parser/conftest.py | 2 +- pandas/tests/io/parser/test_compression.py | 4 +- pandas/tests/io/parser/test_converters.py | 2 +- pandas/tests/io/parser/test_dtypes.py | 4 +- pandas/tests/io/parser/test_mangle_dupes.py | 2 +- pandas/tests/plotting/frame/test_frame.py | 8 +- .../tests/plotting/frame/test_frame_color.py | 13 ++-- pandas/tests/plotting/test_datetimelike.py | 2 +- pandas/tests/resample/test_datetime_index.py | 8 +- pandas/tests/reshape/concat/test_empty.py | 2 +- pandas/tests/reshape/concat/test_invalid.py | 2 +- .../merge/test_merge_index_as_string.py | 20 ++--- pandas/tests/reshape/test_cut.py | 8 +- pandas/tests/reshape/test_qcut.py | 8 +- pandas/tests/series/indexing/test_datetime.py | 2 +- pandas/tests/series/indexing/test_indexing.py | 8 +- .../tests/series/methods/test_interpolate.py | 4 +- pandas/tests/tseries/holiday/test_holiday.py | 16 ++-- pandas/tests/tseries/offsets/test_offsets.py | 4 +- pandas/tests/tslibs/test_to_offset.py | 18 ++--- .../util/test_assert_categorical_equal.py | 2 +- pandas/tests/util/test_assert_frame_equal.py | 4 +- pandas/tests/util/test_validate_args.py | 4 +- pandas/tests/util/test_validate_kwargs.py | 2 +- pandas/util/_print_versions.py | 2 +- 76 files changed, 271 insertions(+), 255 deletions(-) diff --git a/pandas/_testing.py b/pandas/_testing.py index 68371b782aac2..bfff4301c2220 100644 --- a/pandas/_testing.py +++ b/pandas/_testing.py @@ -2167,15 +2167,15 @@ def makeCustomIndex( names = [names] # specific 1D index type requested? - idx_func = dict( - i=makeIntIndex, - f=makeFloatIndex, - s=makeStringIndex, - u=makeUnicodeIndex, - dt=makeDateIndex, - td=makeTimedeltaIndex, - p=makePeriodIndex, - ).get(idx_type) + idx_func = { + "i": makeIntIndex, + "f": makeFloatIndex, + "s": makeStringIndex, + "u": makeUnicodeIndex, + "dt": makeDateIndex, + "td": makeTimedeltaIndex, + "p": makePeriodIndex, + }.get(idx_type) if idx_func: # pandas\_testing.py:2120: error: Cannot call function of unknown type idx = idx_func(nentries) # type: ignore[operator] diff --git a/pandas/compat/numpy/function.py b/pandas/compat/numpy/function.py index c2e91c7877d35..8db999e79fad8 100644 --- a/pandas/compat/numpy/function.py +++ b/pandas/compat/numpy/function.py @@ -71,7 +71,7 @@ def __call__( raise ValueError(f"invalid validation method '{method}'") -ARGMINMAX_DEFAULTS = dict(out=None) +ARGMINMAX_DEFAULTS = {"out": None} validate_argmin = CompatValidator( ARGMINMAX_DEFAULTS, fname="argmin", method="both", max_fname_arg_count=1 ) @@ -151,7 +151,7 @@ def validate_argsort_with_ascending(ascending, args, kwargs): return ascending -CLIP_DEFAULTS: Dict[str, Any] = dict(out=None) +CLIP_DEFAULTS: Dict[str, Any] = {"out": None} validate_clip = CompatValidator( CLIP_DEFAULTS, fname="clip", method="both", max_fname_arg_count=3 ) @@ -208,10 +208,10 @@ def validate_cum_func_with_skipna(skipna, args, kwargs, name): ALLANY_DEFAULTS, fname="any", method="both", max_fname_arg_count=1 ) -LOGICAL_FUNC_DEFAULTS = dict(out=None, keepdims=False) +LOGICAL_FUNC_DEFAULTS = {"out": None, "keepdims": False} validate_logical_func = CompatValidator(LOGICAL_FUNC_DEFAULTS, method="kwargs") -MINMAX_DEFAULTS = dict(axis=None, out=None, keepdims=False) +MINMAX_DEFAULTS = {"axis": None, "out": None, "keepdims": False} validate_min = CompatValidator( MINMAX_DEFAULTS, fname="min", method="both", max_fname_arg_count=1 ) @@ -219,17 +219,17 @@ def validate_cum_func_with_skipna(skipna, args, kwargs, name): MINMAX_DEFAULTS, fname="max", method="both", max_fname_arg_count=1 ) -RESHAPE_DEFAULTS: Dict[str, str] = dict(order="C") +RESHAPE_DEFAULTS: Dict[str, str] = {"order": "C"} validate_reshape = CompatValidator( RESHAPE_DEFAULTS, fname="reshape", method="both", max_fname_arg_count=1 ) -REPEAT_DEFAULTS: Dict[str, Any] = dict(axis=None) +REPEAT_DEFAULTS: Dict[str, Any] = {"axis": None} validate_repeat = CompatValidator( REPEAT_DEFAULTS, fname="repeat", method="both", max_fname_arg_count=1 ) -ROUND_DEFAULTS: Dict[str, Any] = dict(out=None) +ROUND_DEFAULTS: Dict[str, Any] = {"out": None} validate_round = CompatValidator( ROUND_DEFAULTS, fname="round", method="both", max_fname_arg_count=1 ) @@ -300,7 +300,7 @@ def validate_take_with_convert(convert, args, kwargs): return convert -TRANSPOSE_DEFAULTS = dict(axes=None) +TRANSPOSE_DEFAULTS = {"axis": None} validate_transpose = CompatValidator( TRANSPOSE_DEFAULTS, fname="transpose", method="both", max_fname_arg_count=0 ) diff --git a/pandas/core/arrays/_mixins.py b/pandas/core/arrays/_mixins.py index 5cc6525dc3c9b..02214ff51b02a 100644 --- a/pandas/core/arrays/_mixins.py +++ b/pandas/core/arrays/_mixins.py @@ -162,7 +162,7 @@ def repeat( -------- numpy.ndarray.repeat """ - nv.validate_repeat(tuple(), dict(axis=axis)) + nv.validate_repeat((), {"axis": axis}) new_data = self._ndarray.repeat(repeats, axis=axis) return self._from_backing_data(new_data) diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index c591f81390388..b8375af797b3a 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -58,7 +58,7 @@ SparseArrayT = TypeVar("SparseArrayT", bound="SparseArray") -_sparray_doc_kwargs = dict(klass="SparseArray") +_sparray_doc_kwargs = {"klass": "SparseArray"} def _get_fill(arr: "SparseArray") -> np.ndarray: diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index 998117cc49d50..0921c3460c626 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -373,7 +373,7 @@ def sum( min_count: int = 0, ): nv.validate_sum( - (), dict(dtype=dtype, out=out, keepdims=keepdims, initial=initial) + (), {"dtype": dtype, "out": out, "keepdims": keepdims, "initial": initial} ) result = nanops.nansum( @@ -391,7 +391,7 @@ def std( skipna: bool = True, ): nv.validate_stat_ddof_func( - (), dict(dtype=dtype, out=out, keepdims=keepdims), fname="std" + (), {"dtype": dtype, "out": out, "keepdims": keepdims}, fname="std" ) result = nanops.nanstd(self._ndarray, axis=axis, skipna=skipna, ddof=ddof) diff --git a/pandas/core/base.py b/pandas/core/base.py index 5f724d9e89d05..f333ee0f71e46 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -46,13 +46,13 @@ if TYPE_CHECKING: from pandas import Categorical -_shared_docs: Dict[str, str] = dict() -_indexops_doc_kwargs = dict( - klass="IndexOpsMixin", - inplace="", - unique="IndexOpsMixin", - duplicated="IndexOpsMixin", -) +_shared_docs: Dict[str, str] = {} +_indexops_doc_kwargs = { + "klass": "IndexOpsMixin", + "inplace": "", + "unique": "IndexOpsMixin", + "duplicated": "IndexOpsMixin", +} _T = TypeVar("_T", bound="IndexOpsMixin") diff --git a/pandas/core/dtypes/generic.py b/pandas/core/dtypes/generic.py index 0e5867809fe52..d95d8bd4b694e 100644 --- a/pandas/core/dtypes/generic.py +++ b/pandas/core/dtypes/generic.py @@ -18,9 +18,9 @@ def create_pandas_abc_type(name, attr, comp): def _check(cls, inst) -> bool: return getattr(inst, attr, "_typ") in comp - dct = dict(__instancecheck__=_check, __subclasscheck__=_check) + dct = {"__instancecheck__": _check, "__subclasscheck__": _check} meta = type("ABCBase", (type,), dct) - return meta(name, tuple(), dct) + return meta(name, (), dct) ABCInt64Index = create_pandas_abc_type("ABCInt64Index", "_typ", ("int64index",)) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index ae3612c99d5cd..7c97725f1264c 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -85,8 +85,8 @@ class providing the base-class of operations. to each row or column of a DataFrame. """ -_apply_docs = dict( - template=""" +_apply_docs = { + "template": """ Apply function `func` group-wise and combine the results together. The function passed to `apply` must take a {input} as its first @@ -123,7 +123,7 @@ class providing the base-class of operations. Series.apply : Apply a function to a Series. DataFrame.apply : Apply a function to each row or column of a DataFrame. """, - dataframe_examples=""" + "dataframe_examples": """ >>> df = pd.DataFrame({'A': 'a a b'.split(), 'B': [1,2,3], 'C': [4,6, 5]}) @@ -163,7 +163,7 @@ class providing the base-class of operations. b 2 dtype: int64 """, - series_examples=""" + "series_examples": """ >>> s = pd.Series([0, 1, 2], index='a a b'.split()) >>> g = s.groupby(s.index) @@ -202,7 +202,7 @@ class providing the base-class of operations. -------- {examples} """, -) +} _groupby_agg_method_template = """ Compute {fname} of group values. diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index e2507aeaeb652..7956b3a623333 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -27,7 +27,7 @@ import pandas.core.missing as missing _index_doc_kwargs = dict(ibase._index_doc_kwargs) -_index_doc_kwargs.update(dict(target_klass="CategoricalIndex")) +_index_doc_kwargs.update({"target_klass": "CategoricalIndex"}) @inherit_names( diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index 1b18f04ba603d..28ff5a8bacc71 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -200,7 +200,7 @@ def __contains__(self, key: Any) -> bool: @Appender(_index_shared_docs["take"] % _index_doc_kwargs) def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs): - nv.validate_take(tuple(), kwargs) + nv.validate_take((), kwargs) indices = np.asarray(indices, dtype=np.intp) maybe_slice = lib.maybe_indices_to_slice(indices, len(self)) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index f6eeb121b1ac0..f12b8f51b3bfc 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -337,7 +337,7 @@ def __reduce__(self): # we use a special reduce here because we need # to simply set the .tz (and not reinterpret it) - d = dict(data=self._data) + d = {"data": self._data} d.update(self._get_attributes_dict()) return _new_DatetimeIndex, (type(self), d), None diff --git a/pandas/core/indexes/extension.py b/pandas/core/indexes/extension.py index 6c35b882b5d67..a4642c0eb63d6 100644 --- a/pandas/core/indexes/extension.py +++ b/pandas/core/indexes/extension.py @@ -269,7 +269,7 @@ def _get_engine_target(self) -> np.ndarray: return np.asarray(self._data) def repeat(self, repeats, axis=None): - nv.validate_repeat(tuple(), dict(axis=axis)) + nv.validate_repeat((), {"axis": axis}) result = self._data.repeat(repeats, axis=axis) return type(self)._simple_new(result, name=self.name) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 5dff07ee4c6dd..b223e583d0ce0 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -43,7 +43,7 @@ from pandas.core.ops import get_op_result_name _index_doc_kwargs = dict(ibase._index_doc_kwargs) -_index_doc_kwargs.update(dict(target_klass="PeriodIndex or list of Periods")) +_index_doc_kwargs.update({"target_klass": "PeriodIndex or list of Periods"}) # --- Period index sketch diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 4cd7cc56144d9..15b85b3200da3 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -267,7 +267,7 @@ def __getstate__(self): "0.14.1": { "axes": axes_array, "blocks": [ - dict(values=b.values, mgr_locs=b.mgr_locs.indexer) + {"values": b.values, "mgr_locs": b.mgr_locs.indexer} for b in self.blocks ], } diff --git a/pandas/core/resample.py b/pandas/core/resample.py index e5589b0dae837..afd189ad16b5d 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -43,7 +43,7 @@ from pandas.tseries.frequencies import is_subperiod, is_superperiod from pandas.tseries.offsets import DateOffset, Day, Nano, Tick -_shared_docs_kwargs: Dict[str, str] = dict() +_shared_docs_kwargs: Dict[str, str] = {} class Resampler(BaseGroupBy, ShallowMixin): diff --git a/pandas/core/reshape/melt.py b/pandas/core/reshape/melt.py index bcdb223415813..3c4c42886b396 100644 --- a/pandas/core/reshape/melt.py +++ b/pandas/core/reshape/melt.py @@ -22,7 +22,7 @@ from pandas import DataFrame, Series -@Appender(_shared_docs["melt"] % dict(caller="pd.melt(df, ", other="DataFrame.melt")) +@Appender(_shared_docs["melt"] % {"caller": "pd.melt(df, ", "other": "DataFrame.melt"}) def melt( frame: "DataFrame", id_vars=None, diff --git a/pandas/core/shared_docs.py b/pandas/core/shared_docs.py index 9de9d1f434a12..3aeb3b664b27f 100644 --- a/pandas/core/shared_docs.py +++ b/pandas/core/shared_docs.py @@ -1,6 +1,6 @@ from typing import Dict -_shared_docs: Dict[str, str] = dict() +_shared_docs: Dict[str, str] = {} _shared_docs[ "aggregate" diff --git a/pandas/core/util/numba_.py b/pandas/core/util/numba_.py index 1dd005c1602a5..ed920c174ea69 100644 --- a/pandas/core/util/numba_.py +++ b/pandas/core/util/numba_.py @@ -9,7 +9,7 @@ from pandas.errors import NumbaUtilError GLOBAL_USE_NUMBA: bool = False -NUMBA_FUNC_CACHE: Dict[Tuple[Callable, str], Callable] = dict() +NUMBA_FUNC_CACHE: Dict[Tuple[Callable, str], Callable] = {} def maybe_use_numba(engine: Optional[str]) -> bool: diff --git a/pandas/io/formats/csvs.py b/pandas/io/formats/csvs.py index fbda78a1842ca..6d14d6172aa6c 100644 --- a/pandas/io/formats/csvs.py +++ b/pandas/io/formats/csvs.py @@ -159,13 +159,13 @@ def _initialize_chunksize(self, chunksize: Optional[int]) -> int: @property def _number_format(self) -> Dict[str, Any]: """Dictionary used for storing number formatting settings.""" - return dict( - na_rep=self.na_rep, - float_format=self.float_format, - date_format=self.date_format, - quoting=self.quoting, - decimal=self.decimal, - ) + return { + "na_rep": self.na_rep, + "float_format": self.float_format, + "date_format": self.date_format, + "quoting": self.quoting, + "decimal": self.decimal, + } @property def data_index(self) -> Index: diff --git a/pandas/io/formats/printing.py b/pandas/io/formats/printing.py index ac453839792f3..128e50d84657c 100644 --- a/pandas/io/formats/printing.py +++ b/pandas/io/formats/printing.py @@ -206,7 +206,7 @@ def as_escaped_string( translate = escape_chars escape_chars = list(escape_chars.keys()) else: - escape_chars = escape_chars or tuple() + escape_chars = escape_chars or () result = str(thing) for c in escape_chars: diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 0eeff44d0f74c..4557c10927a15 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -433,16 +433,16 @@ def format_attr(pair): else: table_attr += ' class="tex2jax_ignore"' - return dict( - head=head, - cellstyle=cellstyle, - body=body, - uuid=uuid, - precision=precision, - table_styles=table_styles, - caption=caption, - table_attributes=table_attr, - ) + return { + "head": head, + "cellstyle": cellstyle, + "body": body, + "uuid": uuid, + "precision": precision, + "table_styles": table_styles, + "caption": caption, + "table_attributes": table_attr, + } def format(self, formatter, subset=None, na_rep: Optional[str] = None) -> "Styler": """ diff --git a/pandas/io/json/_json.py b/pandas/io/json/_json.py index e1feb1aa3fada..b1d705439e300 100644 --- a/pandas/io/json/_json.py +++ b/pandas/io/json/_json.py @@ -1098,7 +1098,7 @@ def _process_converter(self, f, filt=None): assert obj is not None # for mypy needs_new_obj = False - new_obj = dict() + new_obj = {} for i, (col, c) in enumerate(obj.items()): if filt(col, c): new_data, result = f(col, c) diff --git a/pandas/io/stata.py b/pandas/io/stata.py index d97ba6183c955..6f296d3c8d92f 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -1464,7 +1464,7 @@ def _read_value_labels(self) -> None: off = off[ii] val = val[ii] txt = self.path_or_buf.read(txtlen) - self.value_label_dict[labname] = dict() + self.value_label_dict[labname] = {} for i in range(n): end = off[i + 1] if i < n - 1 else txtlen self.value_label_dict[labname][val[i]] = self._decode(txt[off[i] : end]) diff --git a/pandas/tests/arithmetic/test_timedelta64.py b/pandas/tests/arithmetic/test_timedelta64.py index 0202337a4389a..22c1951a1bce4 100644 --- a/pandas/tests/arithmetic/test_timedelta64.py +++ b/pandas/tests/arithmetic/test_timedelta64.py @@ -822,7 +822,7 @@ def test_operators_timedelta64(self): tm.assert_series_equal(rs, xp) assert rs.dtype == "timedelta64[ns]" - df = DataFrame(dict(A=v1)) + df = DataFrame({"A": "v1"}) td = Series([timedelta(days=i) for i in range(3)]) assert td.dtype == "timedelta64[ns]" diff --git a/pandas/tests/arrays/categorical/test_missing.py b/pandas/tests/arrays/categorical/test_missing.py index cb0ba128c1fb7..36ed790eff63c 100644 --- a/pandas/tests/arrays/categorical/test_missing.py +++ b/pandas/tests/arrays/categorical/test_missing.py @@ -62,13 +62,13 @@ def test_set_item_nan(self): "fillna_kwargs, msg", [ ( - dict(value=1, method="ffill"), + {"value": 1, "method": "ffill"}, "Cannot specify both 'value' and 'method'.", ), - (dict(), "Must specify a fill 'value' or 'method'."), - (dict(method="bad"), "Invalid fill method. Expecting .* bad"), + ({}, "Must specify a fill 'value' or 'method'."), + ({"method": "bad"}, "Invalid fill method. Expecting .* bad"), ( - dict(value=Series([1, 2, 3, 4, "a"])), + {"value": Series([1, 2, 3, 4, "a"])}, "Cannot setitem on a Categorical with a new category", ), ], diff --git a/pandas/tests/arrays/sparse/test_libsparse.py b/pandas/tests/arrays/sparse/test_libsparse.py index 517dc4a2c3d8b..992dff218415d 100644 --- a/pandas/tests/arrays/sparse/test_libsparse.py +++ b/pandas/tests/arrays/sparse/test_libsparse.py @@ -12,42 +12,47 @@ TEST_LENGTH = 20 -plain_case = dict( - xloc=[0, 7, 15], - xlen=[3, 5, 5], - yloc=[2, 9, 14], - ylen=[2, 3, 5], - intersect_loc=[2, 9, 15], - intersect_len=[1, 3, 4], -) -delete_blocks = dict( - xloc=[0, 5], xlen=[4, 4], yloc=[1], ylen=[4], intersect_loc=[1], intersect_len=[3] -) -split_blocks = dict( - xloc=[0], - xlen=[10], - yloc=[0, 5], - ylen=[3, 7], - intersect_loc=[0, 5], - intersect_len=[3, 5], -) -skip_block = dict( - xloc=[10], - xlen=[5], - yloc=[0, 12], - ylen=[5, 3], - intersect_loc=[12], - intersect_len=[3], -) - -no_intersect = dict( - xloc=[0, 10], - xlen=[4, 6], - yloc=[5, 17], - ylen=[4, 2], - intersect_loc=[], - intersect_len=[], -) +plain_case = { + "xloc": [0, 7, 15], + "xlen": [3, 5, 5], + "yloc": [2, 9, 14], + "ylen": [2, 3, 5], + "intersect_loc": [2, 9, 15], + "intersect_len": [1, 3, 4], +} +delete_blocks = { + "xloc": [0, 5], + "xlen": [4, 4], + "yloc": [1], + "ylen": [4], + "intersect_loc": [1], + "intersect_len": [3], +} +split_blocks = { + "xloc": [0], + "xlen": [10], + "yloc": [0, 5], + "ylen": [3, 7], + "intersect_loc": [0, 5], + "intersect_len": [3, 5], +} +skip_block = { + "xloc": [10], + "xlen": [5], + "yloc": [0, 12], + "ylen": [5, 3], + "intersect_loc": [12], + "intersect_len": [3], +} + +no_intersect = { + "xloc": [0, 10], + "xlen": [4, 6], + "yloc": [5, 17], + "ylen": [4, 2], + "intersect_loc": [], + "intersect_len": [], +} def check_cases(_check_case): diff --git a/pandas/tests/dtypes/test_common.py b/pandas/tests/dtypes/test_common.py index 2db9a9a403e1c..ce6737db44195 100644 --- a/pandas/tests/dtypes/test_common.py +++ b/pandas/tests/dtypes/test_common.py @@ -105,16 +105,16 @@ def test_period_dtype(self, dtype): assert com.pandas_dtype(dtype) == dtype -dtypes = dict( - datetime_tz=com.pandas_dtype("datetime64[ns, US/Eastern]"), - datetime=com.pandas_dtype("datetime64[ns]"), - timedelta=com.pandas_dtype("timedelta64[ns]"), - period=PeriodDtype("D"), - integer=np.dtype(np.int64), - float=np.dtype(np.float64), - object=np.dtype(object), - category=com.pandas_dtype("category"), -) +dtypes = { + "datetime_tz": com.pandas_dtype("datetime64[ns, US/Eastern]"), + "datetime": com.pandas_dtype("datetime64[ns]"), + "timedelta": com.pandas_dtype("timedelta64[ns]"), + "period": PeriodDtype("D"), + "integer": np.dtype(np.int64), + "float": np.dtype(np.float64), + "object": np.dtype(object), + "category": com.pandas_dtype("category"), +} @pytest.mark.parametrize("name1,dtype1", list(dtypes.items()), ids=lambda x: str(x)) diff --git a/pandas/tests/extension/base/methods.py b/pandas/tests/extension/base/methods.py index 29a59cdefbd83..1cc03d4f4f2bd 100644 --- a/pandas/tests/extension/base/methods.py +++ b/pandas/tests/extension/base/methods.py @@ -447,10 +447,10 @@ def test_repeat(self, data, repeats, as_series, use_numpy): @pytest.mark.parametrize( "repeats, kwargs, error, msg", [ - (2, dict(axis=1), ValueError, "axis"), - (-1, dict(), ValueError, "negative"), - ([1, 2], dict(), ValueError, "shape"), - (2, dict(foo="bar"), TypeError, "'foo'"), + (2, {"axis": 1}, ValueError, "axis"), + (-1, {}, ValueError, "negative"), + ([1, 2], {}, ValueError, "shape"), + (2, {"foo": "bar"}, TypeError, "'foo'"), ], ) def test_repeat_raises(self, data, repeats, kwargs, error, msg, use_numpy): diff --git a/pandas/tests/frame/common.py b/pandas/tests/frame/common.py index 73e60ff389038..95ebaa4641d1b 100644 --- a/pandas/tests/frame/common.py +++ b/pandas/tests/frame/common.py @@ -5,7 +5,7 @@ def _check_mixed_float(df, dtype=None): # float16 are most likely to be upcasted to float32 - dtypes = dict(A="float32", B="float32", C="float16", D="float64") + dtypes = {"A": "float32", "B": "float32", "C": "float16", "D": "float64"} if isinstance(dtype, str): dtypes = {k: dtype for k, v in dtypes.items()} elif isinstance(dtype, dict): @@ -21,7 +21,7 @@ def _check_mixed_float(df, dtype=None): def _check_mixed_int(df, dtype=None): - dtypes = dict(A="int32", B="uint64", C="uint8", D="int64") + dtypes = {"A": "int32", "B": "uint64", "C": "uint8", "D": "int64"} if isinstance(dtype, str): dtypes = {k: dtype for k, v in dtypes.items()} elif isinstance(dtype, dict): diff --git a/pandas/tests/frame/methods/test_astype.py b/pandas/tests/frame/methods/test_astype.py index f05c90f37ea8a..d79969eac0323 100644 --- a/pandas/tests/frame/methods/test_astype.py +++ b/pandas/tests/frame/methods/test_astype.py @@ -563,7 +563,7 @@ def test_astype_empty_dtype_dict(self): # issue mentioned further down in the following issue's thread # https://github.com/pandas-dev/pandas/issues/33113 df = DataFrame() - result = df.astype(dict()) + result = df.astype({}) tm.assert_frame_equal(result, df) assert result is not df diff --git a/pandas/tests/frame/methods/test_convert.py b/pandas/tests/frame/methods/test_convert.py index 50add248f9614..a00b2b5960884 100644 --- a/pandas/tests/frame/methods/test_convert.py +++ b/pandas/tests/frame/methods/test_convert.py @@ -43,9 +43,9 @@ def test_convert_objects(self, float_string_frame): converted["H"].astype("int32") # mixed in a single column - df = DataFrame(dict(s=Series([1, "na", 3, 4]))) + df = DataFrame({"s": Series([1, "na", 3, 4])}) result = df._convert(datetime=True, numeric=True) - expected = DataFrame(dict(s=Series([1, np.nan, 3, 4]))) + expected = DataFrame({"s": Series([1, np.nan, 3, 4])}) tm.assert_frame_equal(result, expected) def test_convert_objects_no_conversion(self): diff --git a/pandas/tests/frame/methods/test_diff.py b/pandas/tests/frame/methods/test_diff.py index 8affcce478cf4..b8328b43a6b13 100644 --- a/pandas/tests/frame/methods/test_diff.py +++ b/pandas/tests/frame/methods/test_diff.py @@ -132,10 +132,10 @@ def test_diff_datetime_axis1(self, tz): def test_diff_timedelta(self): # GH#4533 df = DataFrame( - dict( - time=[Timestamp("20130101 9:01"), Timestamp("20130101 9:02")], - value=[1.0, 2.0], - ) + { + "time": [Timestamp("20130101 9:01"), Timestamp("20130101 9:02")], + "value": [1.0, 2.0], + } ) res = df.diff() diff --git a/pandas/tests/frame/methods/test_rename.py b/pandas/tests/frame/methods/test_rename.py index 857dd0ad7268b..1080d97b30987 100644 --- a/pandas/tests/frame/methods/test_rename.py +++ b/pandas/tests/frame/methods/test_rename.py @@ -76,8 +76,8 @@ def test_rename(self, float_frame): @pytest.mark.parametrize( "args,kwargs", [ - ((ChainMap({"A": "a"}, {"B": "b"}),), dict(axis="columns")), - ((), dict(columns=ChainMap({"A": "a"}, {"B": "b"}))), + ((ChainMap({"A": "a"}, {"B": "b"}),), {"axis": "columns"}), + ((), {"columns": ChainMap({"A": "a"}, {"B": "b"})}), ], ) def test_rename_chainmap(self, args, kwargs): diff --git a/pandas/tests/frame/methods/test_replace.py b/pandas/tests/frame/methods/test_replace.py index 8e59dd959ab57..ab750bca7e069 100644 --- a/pandas/tests/frame/methods/test_replace.py +++ b/pandas/tests/frame/methods/test_replace.py @@ -1123,7 +1123,7 @@ def test_replace_series_no_regex(self): tm.assert_series_equal(result, expected) def test_replace_dict_tuple_list_ordering_remains_the_same(self): - df = DataFrame(dict(A=[np.nan, 1])) + df = DataFrame({"A": [np.nan, 1]}) res1 = df.replace(to_replace={np.nan: 0, 1: -1e8}) res2 = df.replace(to_replace=(1, np.nan), value=[-1e8, 0]) res3 = df.replace(to_replace=[1, np.nan], value=[-1e8, 0]) diff --git a/pandas/tests/frame/methods/test_reset_index.py b/pandas/tests/frame/methods/test_reset_index.py index 5864b547a552b..00d4a4277a42f 100644 --- a/pandas/tests/frame/methods/test_reset_index.py +++ b/pandas/tests/frame/methods/test_reset_index.py @@ -618,7 +618,7 @@ def test_reset_index_empty_frame_with_datetime64_multiindex(): def test_reset_index_empty_frame_with_datetime64_multiindex_from_groupby(): # https://github.com/pandas-dev/pandas/issues/35657 - df = DataFrame(dict(c1=[10.0], c2=["a"], c3=pd.to_datetime("2020-01-01"))) + df = DataFrame({"c1": [10.0], "c2": ["a"], "c3": pd.to_datetime("2020-01-01")}) df = df.head(0).groupby(["c2", "c3"])[["c1"]].sum() result = df.reset_index() expected = DataFrame( diff --git a/pandas/tests/frame/test_nonunique_indexes.py b/pandas/tests/frame/test_nonunique_indexes.py index 109561a5acb23..b42c56f256478 100644 --- a/pandas/tests/frame/test_nonunique_indexes.py +++ b/pandas/tests/frame/test_nonunique_indexes.py @@ -250,7 +250,7 @@ def test_column_dups_operations(self): # operations for op in ["__add__", "__mul__", "__sub__", "__truediv__"]: - df = DataFrame(dict(A=np.arange(10), B=np.random.rand(10))) + df = DataFrame({"A": np.arange(10), "B": np.random.rand(10)}) expected = getattr(df, op)(df) expected.columns = ["A", "A"] df.columns = ["A", "A"] diff --git a/pandas/tests/frame/test_query_eval.py b/pandas/tests/frame/test_query_eval.py index f3f2bbe1d160e..af134db587306 100644 --- a/pandas/tests/frame/test_query_eval.py +++ b/pandas/tests/frame/test_query_eval.py @@ -127,7 +127,7 @@ def test_ops(self, op_str, op, rop, n): def test_dataframe_sub_numexpr_path(self): # GH7192: Note we need a large number of rows to ensure this # goes through the numexpr path - df = DataFrame(dict(A=np.random.randn(25000))) + df = DataFrame({"A": np.random.randn(25000)}) df.iloc[0:5] = np.nan expected = 1 - np.isnan(df.iloc[0:25]) result = (1 - np.isnan(df)).iloc[0:25] diff --git a/pandas/tests/frame/test_stack_unstack.py b/pandas/tests/frame/test_stack_unstack.py index c70bfc4a3602b..c9e737a9dcb0f 100644 --- a/pandas/tests/frame/test_stack_unstack.py +++ b/pandas/tests/frame/test_stack_unstack.py @@ -336,19 +336,19 @@ def test_unstack_mixed_type_name_in_multiindex( def test_unstack_preserve_dtypes(self): # Checks fix for #11847 df = DataFrame( - dict( - state=["IL", "MI", "NC"], - index=["a", "b", "c"], - some_categories=Series(["a", "b", "c"]).astype("category"), - A=np.random.rand(3), - B=1, - C="foo", - D=pd.Timestamp("20010102"), - E=Series([1.0, 50.0, 100.0]).astype("float32"), - F=Series([3.0, 4.0, 5.0]).astype("float64"), - G=False, - H=Series([1, 200, 923442], dtype="int8"), - ) + { + "state": ["IL", "MI", "NC"], + "index": ["a", "b", "c"], + "some_categories": Series(["a", "b", "c"]).astype("category"), + "A": np.random.rand(3), + "B": 1, + "C": "foo", + "D": pd.Timestamp("20010102"), + "E": Series([1.0, 50.0, 100.0]).astype("float32"), + "F": Series([3.0, 4.0, 5.0]).astype("float64"), + "G": False, + "H": Series([1, 200, 923442], dtype="int8"), + } ) def unstack_and_compare(df, column_name): @@ -1689,7 +1689,7 @@ def test_stack_multiple_bug(self): name = (["a"] * 3) + (["b"] * 3) date = pd.to_datetime(["2013-01-03", "2013-01-04", "2013-01-05"] * 2) var1 = np.random.randint(0, 100, 6) - df = DataFrame(dict(ID=id_col, NAME=name, DATE=date, VAR1=var1)) + df = DataFrame({"ID": id_col, "NAME": name, "DATE": date, "VAR1": var1}) multi = df.set_index(["DATE", "ID"]) multi.columns.name = "Params" diff --git a/pandas/tests/frame/test_ufunc.py b/pandas/tests/frame/test_ufunc.py index 7bc9aa29af3b4..81c0dc65b4e97 100644 --- a/pandas/tests/frame/test_ufunc.py +++ b/pandas/tests/frame/test_ufunc.py @@ -7,7 +7,7 @@ dtypes = [ "int64", "Int64", - dict(A="int64", B="Int64"), + {"A": "int64", "B": "Int64"}, ] diff --git a/pandas/tests/frame/test_validate.py b/pandas/tests/frame/test_validate.py index c7270322b980c..e99e0a6863848 100644 --- a/pandas/tests/frame/test_validate.py +++ b/pandas/tests/frame/test_validate.py @@ -26,7 +26,7 @@ class TestDataFrameValidate: @pytest.mark.parametrize("inplace", [1, "True", [1, 2, 3], 5.0]) def test_validate_bool_args(self, dataframe, func, inplace): msg = 'For argument "inplace" expected type bool' - kwargs = dict(inplace=inplace) + kwargs = {"inplace": inplace} if func == "query": kwargs["expr"] = "a > b" diff --git a/pandas/tests/generic/test_duplicate_labels.py b/pandas/tests/generic/test_duplicate_labels.py index 300f4cd72573a..1b32675ec2d35 100644 --- a/pandas/tests/generic/test_duplicate_labels.py +++ b/pandas/tests/generic/test_duplicate_labels.py @@ -203,7 +203,7 @@ def test_concat(self, objs, kwargs): pd.DataFrame({"B": [0, 1]}, index=["a", "d"]).set_flags( allows_duplicate_labels=False ), - dict(left_index=True, right_index=True), + {"left_index": True, "right_index": True}, False, marks=not_implemented, ), @@ -213,7 +213,7 @@ def test_concat(self, objs, kwargs): allows_duplicate_labels=False ), pd.DataFrame({"B": [0, 1]}, index=["a", "d"]), - dict(left_index=True, right_index=True), + {"left_index": True, "right_index": True}, False, marks=not_implemented, ), @@ -221,7 +221,7 @@ def test_concat(self, objs, kwargs): ( pd.DataFrame({"A": [0, 1]}, index=["a", "b"]), pd.DataFrame({"B": [0, 1]}, index=["a", "d"]), - dict(left_index=True, right_index=True), + {"left_index": True, "right_index": True}, True, ), ], diff --git a/pandas/tests/groupby/test_apply.py b/pandas/tests/groupby/test_apply.py index 151ec03662335..b2074dcb08c95 100644 --- a/pandas/tests/groupby/test_apply.py +++ b/pandas/tests/groupby/test_apply.py @@ -665,7 +665,7 @@ def test_apply_aggregating_timedelta_and_datetime(): df["time_delta_zero"] = df.datetime - df.datetime result = df.groupby("clientid").apply( lambda ddf: Series( - dict(clientid_age=ddf.time_delta_zero.min(), date=ddf.datetime.min()) + {"clientid_age": ddf.time_delta_zero.min(), "date": ddf.datetime.min()} ) ) expected = DataFrame( @@ -784,7 +784,7 @@ def test_func(x): def test_groupby_apply_return_empty_chunk(): # GH 22221: apply filter which returns some empty groups - df = DataFrame(dict(value=[0, 1], group=["filled", "empty"])) + df = DataFrame({"value": [0, 1], "group": ["filled", "empty"]}) groups = df.groupby("group") result = groups.apply(lambda group: group[group.value != 1]["value"]) expected = Series( diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index 78c438fa11a0e..7c179a79513fa 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -149,11 +149,11 @@ def test_inconsistent_return_type(): # GH5592 # inconsistent return type df = DataFrame( - dict( - A=["Tiger", "Tiger", "Tiger", "Lamb", "Lamb", "Pony", "Pony"], - B=Series(np.arange(7), dtype="int64"), - C=date_range("20130101", periods=7), - ) + { + "A": ["Tiger", "Tiger", "Tiger", "Lamb", "Lamb", "Pony", "Pony"], + "B": Series(np.arange(7), dtype="int64"), + "C": date_range("20130101", periods=7), + } ) def f(grp): @@ -257,7 +257,7 @@ def test_len(): assert len(grouped) == expected # issue 11016 - df = DataFrame(dict(a=[np.nan] * 3, b=[1, 2, 3])) + df = DataFrame({"a": [np.nan] * 3, "b": [1, 2, 3]}) assert len(df.groupby("a")) == 0 assert len(df.groupby("b")) == 3 assert len(df.groupby(["a", "b"])) == 3 diff --git a/pandas/tests/groupby/test_quantile.py b/pandas/tests/groupby/test_quantile.py index bd6d33c59a48a..53729a120ae8d 100644 --- a/pandas/tests/groupby/test_quantile.py +++ b/pandas/tests/groupby/test_quantile.py @@ -157,7 +157,7 @@ def test_quantile_raises(): def test_quantile_out_of_bounds_q_raises(): # https://github.com/pandas-dev/pandas/issues/27470 - df = DataFrame(dict(a=[0, 0, 0, 1, 1, 1], b=range(6))) + df = DataFrame({"a": [0, 0, 0, 1, 1, 1], "b": range(6)}) g = df.groupby([0, 0, 0, 1, 1, 1]) with pytest.raises(ValueError, match="Got '50.0' instead"): g.quantile(50) @@ -169,7 +169,7 @@ def test_quantile_out_of_bounds_q_raises(): def test_quantile_missing_group_values_no_segfaults(): # GH 28662 data = np.array([1.0, np.nan, 1.0]) - df = DataFrame(dict(key=data, val=range(3))) + df = DataFrame({"key": data, "val": range(3)}) # Random segfaults; would have been guaranteed in loop grp = df.groupby("key") diff --git a/pandas/tests/groupby/test_timegrouper.py b/pandas/tests/groupby/test_timegrouper.py index 2340168415382..28095c0b0c39f 100644 --- a/pandas/tests/groupby/test_timegrouper.py +++ b/pandas/tests/groupby/test_timegrouper.py @@ -651,7 +651,7 @@ def test_groupby_first_datetime64(self): def test_groupby_max_datetime64(self): # GH 5869 # datetimelike dtype conversion from int - df = DataFrame(dict(A=Timestamp("20130101"), B=np.arange(5))) + df = DataFrame({"A": Timestamp("20130101"), "B": np.arange(5)}) expected = df.groupby("A")["A"].apply(lambda x: x.max()) result = df.groupby("A")["A"].max() tm.assert_series_equal(result, expected) diff --git a/pandas/tests/groupby/test_value_counts.py b/pandas/tests/groupby/test_value_counts.py index c86cb4532bc26..c5d454baa7e7b 100644 --- a/pandas/tests/groupby/test_value_counts.py +++ b/pandas/tests/groupby/test_value_counts.py @@ -65,9 +65,13 @@ def rebuild_index(df): df.index = MultiIndex.from_arrays(arr, names=df.index.names) return df - kwargs = dict( - normalize=normalize, sort=sort, ascending=ascending, dropna=dropna, bins=bins - ) + kwargs = { + "normalize": normalize, + "sort": sort, + "ascending": ascending, + "dropna": dropna, + "bins": bins, + } gr = df.groupby(keys, sort=isort) left = gr["3rd"].value_counts(**kwargs) diff --git a/pandas/tests/indexes/period/test_partial_slicing.py b/pandas/tests/indexes/period/test_partial_slicing.py index 878a89bd52cb1..f354682bf6f70 100644 --- a/pandas/tests/indexes/period/test_partial_slicing.py +++ b/pandas/tests/indexes/period/test_partial_slicing.py @@ -94,7 +94,7 @@ def test_range_slice_outofbounds(self, make_range): def test_maybe_cast_slice_bound(self, make_range, frame_or_series): idx = make_range(start="2013/10/01", freq="D", periods=10) - obj = DataFrame(dict(units=[100 + i for i in range(10)]), index=idx) + obj = DataFrame({"units": [100 + i for i in range(10)]}, index=idx) if frame_or_series is not DataFrame: obj = obj["units"] diff --git a/pandas/tests/io/formats/test_to_excel.py b/pandas/tests/io/formats/test_to_excel.py index 8529a0fb33b67..4f1af132204bb 100644 --- a/pandas/tests/io/formats/test_to_excel.py +++ b/pandas/tests/io/formats/test_to_excel.py @@ -278,7 +278,7 @@ def test_css_to_excel_good_colors(input_color, output_color): f"color: {input_color}" ) - expected = dict() + expected = {} expected["fill"] = {"patternType": "solid", "fgColor": output_color} @@ -305,7 +305,7 @@ def test_css_to_excel_bad_colors(input_color): f"color: {input_color}" ) - expected = dict() + expected = {} if input_color is not None: expected["fill"] = {"patternType": "solid"} diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py index aaadc965aca52..a88dec84bd693 100644 --- a/pandas/tests/io/formats/test_to_html.py +++ b/pandas/tests/io/formats/test_to_html.py @@ -152,8 +152,8 @@ def test_to_html_decimal(datapath): @pytest.mark.parametrize( "kwargs,string,expected", [ - (dict(), "", "escaped"), - (dict(escape=False), "bold", "escape_disabled"), + ({}, "", "escaped"), + ({"escape": False}, "bold", "escape_disabled"), ], ) def test_to_html_escaped(kwargs, string, expected, datapath): diff --git a/pandas/tests/io/formats/test_to_latex.py b/pandas/tests/io/formats/test_to_latex.py index 81e8e0bd2b526..ba6d7c010613b 100644 --- a/pandas/tests/io/formats/test_to_latex.py +++ b/pandas/tests/io/formats/test_to_latex.py @@ -92,7 +92,7 @@ def test_to_latex_tabular_without_index(self): @pytest.mark.parametrize( "bad_column_format", - [5, 1.2, ["l", "r"], ("r", "c"), {"r", "c", "l"}, dict(a="r", b="l")], + [5, 1.2, ["l", "r"], ("r", "c"), {"r", "c", "l"}, {"a": "r", "b": "l"}], ) def test_to_latex_bad_column_format(self, bad_column_format): df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]}) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index fdf2caa804def..7a5aca13b33f5 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -379,7 +379,7 @@ def test_frame_infinity(self, orient, inf, dtype): ], ) def test_frame_to_json_float_precision(self, value, precision, expected_val): - df = DataFrame([dict(a_float=value)]) + df = DataFrame([{"a_float": value}]) encoded = df.to_json(double_precision=precision) assert encoded == f'{{"a_float":{{"0":{expected_val}}}}}' @@ -475,8 +475,8 @@ def test_blocks_compat_GH9037(self): index = DatetimeIndex(list(index), freq=None) df_mixed = DataFrame( - dict( - float_1=[ + { + "float_1": [ -0.92077639, 0.77434435, 1.25234727, @@ -488,7 +488,7 @@ def test_blocks_compat_GH9037(self): 0.95748401, -1.02970536, ], - int_1=[ + "int_1": [ 19680418, 75337055, 99973684, @@ -500,7 +500,7 @@ def test_blocks_compat_GH9037(self): 41903419, 16008365, ], - str_1=[ + "str_1": [ "78c608f1", "64a99743", "13d2ff52", @@ -512,7 +512,7 @@ def test_blocks_compat_GH9037(self): "7a669144", "8d64d068", ], - float_2=[ + "float_2": [ -0.0428278, -1.80872357, 3.36042349, @@ -524,7 +524,7 @@ def test_blocks_compat_GH9037(self): -0.03030452, 1.43366348, ], - str_2=[ + "str_2": [ "14f04af9", "d085da90", "4bcfac83", @@ -536,7 +536,7 @@ def test_blocks_compat_GH9037(self): "1f6a09ba", "4bfc4d87", ], - int_2=[ + "int_2": [ 86967717, 98098830, 51927505, @@ -548,7 +548,7 @@ def test_blocks_compat_GH9037(self): 24867120, 76131025, ], - ), + }, index=index, ) diff --git a/pandas/tests/io/parser/conftest.py b/pandas/tests/io/parser/conftest.py index d03c85f65ea8d..e8893b4c02238 100644 --- a/pandas/tests/io/parser/conftest.py +++ b/pandas/tests/io/parser/conftest.py @@ -13,7 +13,7 @@ class BaseParser: def update_kwargs(self, kwargs): kwargs = kwargs.copy() - kwargs.update(dict(engine=self.engine, low_memory=self.low_memory)) + kwargs.update({"engine": self.engine, "low_memory": self.low_memory}) return kwargs diff --git a/pandas/tests/io/parser/test_compression.py b/pandas/tests/io/parser/test_compression.py index 690d3133dae5e..220d9474c6dbf 100644 --- a/pandas/tests/io/parser/test_compression.py +++ b/pandas/tests/io/parser/test_compression.py @@ -109,7 +109,7 @@ def test_compression(parser_and_data, compression_only, buffer, filename): def test_infer_compression(all_parsers, csv1, buffer, ext): # see gh-9770 parser = all_parsers - kwargs = dict(index_col=0, parse_dates=True) + kwargs = {"index_col": 0, "parse_dates": True} expected = parser.read_csv(csv1, **kwargs) kwargs["compression"] = "infer" @@ -144,7 +144,7 @@ def test_compression_utf_encoding(all_parsers, csv_dir_path, utf_value, encoding @pytest.mark.parametrize("invalid_compression", ["sfark", "bz3", "zipper"]) def test_invalid_compression(all_parsers, invalid_compression): parser = all_parsers - compress_kwargs = dict(compression=invalid_compression) + compress_kwargs = {"compression": invalid_compression} msg = f"Unrecognized compression type: {invalid_compression}" diff --git a/pandas/tests/io/parser/test_converters.py b/pandas/tests/io/parser/test_converters.py index 88b400d9a11df..1d2fb7fddc9dd 100644 --- a/pandas/tests/io/parser/test_converters.py +++ b/pandas/tests/io/parser/test_converters.py @@ -57,7 +57,7 @@ def test_converters_no_implicit_conv(all_parsers): def test_converters_euro_decimal_format(all_parsers): # see gh-583 - converters = dict() + converters = {} parser = all_parsers data = """Id;Number1;Number2;Text1;Text2;Number3 diff --git a/pandas/tests/io/parser/test_dtypes.py b/pandas/tests/io/parser/test_dtypes.py index 861aeba60cab7..930ce1a695e1f 100644 --- a/pandas/tests/io/parser/test_dtypes.py +++ b/pandas/tests/io/parser/test_dtypes.py @@ -495,7 +495,7 @@ def test_dtype_with_converters(all_parsers): (np.float64, DataFrame(columns=["a", "b"], dtype=np.float64)), ("category", DataFrame({"a": Categorical([]), "b": Categorical([])}, index=[])), ( - dict(a="category", b="category"), + {"a": "category", "b": "category"}, DataFrame({"a": Categorical([]), "b": Categorical([])}, index=[]), ), ("datetime64[ns]", DataFrame(columns=["a", "b"], dtype="datetime64[ns]")), @@ -510,7 +510,7 @@ def test_dtype_with_converters(all_parsers): ), ), ( - dict(a=np.int64, b=np.int32), + {"a": np.int64, "b": np.int32}, DataFrame( {"a": Series([], dtype=np.int64), "b": Series([], dtype=np.int32)}, index=[], diff --git a/pandas/tests/io/parser/test_mangle_dupes.py b/pandas/tests/io/parser/test_mangle_dupes.py index 5c4e642115798..457a6567febab 100644 --- a/pandas/tests/io/parser/test_mangle_dupes.py +++ b/pandas/tests/io/parser/test_mangle_dupes.py @@ -11,7 +11,7 @@ import pandas._testing as tm -@pytest.mark.parametrize("kwargs", [dict(), dict(mangle_dupe_cols=True)]) +@pytest.mark.parametrize("kwargs", [{}, {"mangle_dupe_cols": True}]) def test_basic(all_parsers, kwargs): # TODO: add test for condition "mangle_dupe_cols=False" # once it is actually supported (gh-12935) diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 77a4c4a8faf5e..4c6ffaf425cf7 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -662,12 +662,12 @@ def test_scatterplot_datetime_data(self): def test_scatterplot_object_data(self): # GH 18755 - df = DataFrame(dict(a=["A", "B", "C"], b=[2, 3, 4])) + df = DataFrame({"a": ["A", "B", "C"], "b": [2, 3, 4]}) _check_plot_works(df.plot.scatter, x="a", y="b") _check_plot_works(df.plot.scatter, x=0, y=1) - df = DataFrame(dict(a=["A", "B", "C"], b=["a", "b", "c"])) + df = DataFrame({"a": ["A", "B", "C"], "b": ["a", "b", "c"]}) _check_plot_works(df.plot.scatter, x="a", y="b") _check_plot_works(df.plot.scatter, x=0, y=1) @@ -1266,7 +1266,7 @@ def test_line_label_none(self): def test_specified_props_kwd_plot_box(self, props, expected): # GH 30346 df = DataFrame({k: np.random.random(100) for k in "ABC"}) - kwd = {props: dict(color="C1")} + kwd = {props: {"color": "C1"}} result = df.plot.box(return_type="dict", **kwd) assert result[expected][0].get_color() == "C1" @@ -2022,7 +2022,7 @@ def test_secondary_axis_font_size(self, method): fontsize = 20 sy = ["C", "D"] - kwargs = dict(secondary_y=sy, fontsize=fontsize, mark_right=True) + kwargs = {"secondary_y": sy, "fontsize": fontsize, "mark_right": True} ax = getattr(df.plot, method)(**kwargs) self._check_ticks_props(axes=ax.right_ax, ylabelsize=fontsize) diff --git a/pandas/tests/plotting/frame/test_frame_color.py b/pandas/tests/plotting/frame/test_frame_color.py index d9fe7363a15ad..f711e9d1092a1 100644 --- a/pandas/tests/plotting/frame/test_frame_color.py +++ b/pandas/tests/plotting/frame/test_frame_color.py @@ -551,9 +551,12 @@ def _check_colors(bp, box_c, whiskers_c, medians_c, caps_c="k", fliers_c=None): _check_colors(bp, default_colors[0], default_colors[0], default_colors[2]) tm.close() - dict_colors = dict( - boxes="#572923", whiskers="#982042", medians="#804823", caps="#123456" - ) + dict_colors = { + "boxes": "#572923", + "whiskers": "#982042", + "medians": "#804823", + "caps": "#123456", + } bp = df.plot.box(color=dict_colors, sym="r+", return_type="dict") _check_colors( bp, @@ -566,7 +569,7 @@ def _check_colors(bp, box_c, whiskers_c, medians_c, caps_c="k", fliers_c=None): tm.close() # partial colors - dict_colors = dict(whiskers="c", medians="m") + dict_colors = {"whiskers": "c", "medians": "m"} bp = df.plot.box(color=dict_colors, return_type="dict") _check_colors(bp, default_colors[0], "c", "m") tm.close() @@ -594,7 +597,7 @@ def _check_colors(bp, box_c, whiskers_c, medians_c, caps_c="k", fliers_c=None): with pytest.raises(ValueError): # Color contains invalid key results in ValueError - df.plot.box(color=dict(boxes="red", xxxx="blue")) + df.plot.box(color={"boxes": "red", "xxxx": "blue"}) def test_default_color_cycle(self): import cycler diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index 590758bc01fbb..3db612bc4afee 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -1277,7 +1277,7 @@ def test_mpl_nopandas(self): values1 = np.arange(10.0, 11.0, 0.5) values2 = np.arange(11.0, 12.0, 0.5) - kw = dict(fmt="-", lw=4) + kw = {"fmt": "-", "lw": 4} _, ax = self.plt.subplots() ax.plot_date([x.toordinal() for x in dates], values1, **kw) diff --git a/pandas/tests/resample/test_datetime_index.py b/pandas/tests/resample/test_datetime_index.py index 65b50e829478d..3e41dab39e71d 100644 --- a/pandas/tests/resample/test_datetime_index.py +++ b/pandas/tests/resample/test_datetime_index.py @@ -1273,7 +1273,7 @@ def test_resample_timegrouper(): dates3 = [pd.NaT] + dates1 + [pd.NaT] for dates in [dates1, dates2, dates3]: - df = DataFrame(dict(A=dates, B=np.arange(len(dates)))) + df = DataFrame({"A": dates, "B": np.arange(len(dates))}) result = df.set_index("A").resample("M").count() exp_idx = DatetimeIndex( ["2014-07-31", "2014-08-31", "2014-09-30", "2014-10-31", "2014-11-30"], @@ -1288,7 +1288,9 @@ def test_resample_timegrouper(): result = df.groupby(Grouper(freq="M", key="A")).count() tm.assert_frame_equal(result, expected) - df = DataFrame(dict(A=dates, B=np.arange(len(dates)), C=np.arange(len(dates)))) + df = DataFrame( + {"A": dates, "B": np.arange(len(dates)), "C": np.arange(len(dates))} + ) result = df.set_index("A").resample("M").count() expected = DataFrame( {"B": [1, 0, 2, 2, 1], "C": [1, 0, 2, 2, 1]}, @@ -1728,7 +1730,7 @@ def test_resample_apply_product(): index = date_range(start="2012-01-31", freq="M", periods=12) ts = Series(range(12), index=index) - df = DataFrame(dict(A=ts, B=ts + 2)) + df = DataFrame({"A": ts, "B": ts + 2}) result = df.resample("Q").apply(np.product) expected = DataFrame( np.array([[0, 24], [60, 210], [336, 720], [990, 1716]], dtype=np.int64), diff --git a/pandas/tests/reshape/concat/test_empty.py b/pandas/tests/reshape/concat/test_empty.py index 5c540124de8e6..a97e9265b4f99 100644 --- a/pandas/tests/reshape/concat/test_empty.py +++ b/pandas/tests/reshape/concat/test_empty.py @@ -26,7 +26,7 @@ def test_handle_empty_objects(self, sort): # empty as first element with time series # GH3259 df = DataFrame( - dict(A=range(10000)), index=date_range("20130101", periods=10000, freq="s") + {"A": range(10000)}, index=date_range("20130101", periods=10000, freq="s") ) empty = DataFrame() result = concat([df, empty], axis=1) diff --git a/pandas/tests/reshape/concat/test_invalid.py b/pandas/tests/reshape/concat/test_invalid.py index 3a886e0d612c6..ec8167906a60c 100644 --- a/pandas/tests/reshape/concat/test_invalid.py +++ b/pandas/tests/reshape/concat/test_invalid.py @@ -12,7 +12,7 @@ def test_concat_invalid(self): # trying to concat a ndframe with a non-ndframe df1 = tm.makeCustomDataframe(10, 2) - for obj in [1, dict(), [1, 2], (1, 2)]: + for obj in [1, {}, [1, 2], (1, 2)]: msg = ( f"cannot concatenate object of type '{type(obj)}'; " diff --git a/pandas/tests/reshape/merge/test_merge_index_as_string.py b/pandas/tests/reshape/merge/test_merge_index_as_string.py index d20d93370ec7e..c3e0a92850c07 100644 --- a/pandas/tests/reshape/merge/test_merge_index_as_string.py +++ b/pandas/tests/reshape/merge/test_merge_index_as_string.py @@ -8,22 +8,22 @@ @pytest.fixture def df1(): return DataFrame( - dict( - outer=[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4], - inner=[1, 2, 3, 1, 2, 3, 4, 1, 2, 1, 2], - v1=np.linspace(0, 1, 11), - ) + { + "outer": [1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4], + "inner": [1, 2, 3, 1, 2, 3, 4, 1, 2, 1, 2], + "v1": np.linspace(0, 1, 11), + } ) @pytest.fixture def df2(): return DataFrame( - dict( - outer=[1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3], - inner=[1, 2, 2, 3, 3, 4, 2, 3, 1, 1, 2, 3], - v2=np.linspace(10, 11, 12), - ) + { + "outer": [1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3], + "inner": [1, 2, 2, 3, 3, 4, 2, 3, 1, 1, 2, 3], + "v2": np.linspace(10, 11, 12), + } ) diff --git a/pandas/tests/reshape/test_cut.py b/pandas/tests/reshape/test_cut.py index 8aa4012b3e77c..4786b8c35a5b1 100644 --- a/pandas/tests/reshape/test_cut.py +++ b/pandas/tests/reshape/test_cut.py @@ -377,10 +377,10 @@ def test_series_ret_bins(): @pytest.mark.parametrize( "kwargs,msg", [ - (dict(duplicates="drop"), None), - (dict(), "Bin edges must be unique"), - (dict(duplicates="raise"), "Bin edges must be unique"), - (dict(duplicates="foo"), "invalid value for 'duplicates' parameter"), + ({"duplicates": "drop"}, None), + ({}, "Bin edges must be unique"), + ({"duplicates": "raise"}, "Bin edges must be unique"), + ({"duplicates": "foo"}, "invalid value for 'duplicates' parameter"), ], ) def test_cut_duplicates_bin(kwargs, msg): diff --git a/pandas/tests/reshape/test_qcut.py b/pandas/tests/reshape/test_qcut.py index c436ab5d90578..e7a04bafed8e3 100644 --- a/pandas/tests/reshape/test_qcut.py +++ b/pandas/tests/reshape/test_qcut.py @@ -166,10 +166,10 @@ def test_qcut_list_like_labels(labels, expected): @pytest.mark.parametrize( "kwargs,msg", [ - (dict(duplicates="drop"), None), - (dict(), "Bin edges must be unique"), - (dict(duplicates="raise"), "Bin edges must be unique"), - (dict(duplicates="foo"), "invalid value for 'duplicates' parameter"), + ({"duplicates": "drop"}, None), + ({}, "Bin edges must be unique"), + ({"duplicates": "raise"}, "Bin edges must be unique"), + ({"duplicates": "foo"}, "invalid value for 'duplicates' parameter"), ], ) def test_qcut_duplicates_bin(kwargs, msg): diff --git a/pandas/tests/series/indexing/test_datetime.py b/pandas/tests/series/indexing/test_datetime.py index 71ddf72562f36..a15ef11f9c292 100644 --- a/pandas/tests/series/indexing/test_datetime.py +++ b/pandas/tests/series/indexing/test_datetime.py @@ -561,7 +561,7 @@ def test_indexing(): expected = ts["2001"] expected.name = "A" - df = DataFrame(dict(A=ts)) + df = DataFrame({"A": ts}) with tm.assert_produces_warning(FutureWarning): # GH#36179 string indexing on rows for DataFrame deprecated result = df["2001"]["A"] diff --git a/pandas/tests/series/indexing/test_indexing.py b/pandas/tests/series/indexing/test_indexing.py index 682c057f05700..3bb87a8346c78 100644 --- a/pandas/tests/series/indexing/test_indexing.py +++ b/pandas/tests/series/indexing/test_indexing.py @@ -667,7 +667,9 @@ def test_underlying_data_conversion(): df df["val"].update(s) - expected = DataFrame(dict(a=[1, 2, 3], b=[1, 2, 3], c=[1, 2, 3], val=[0, 1, 0])) + expected = DataFrame( + {"a": [1, 2, 3], "b": [1, 2, 3], "c": [1, 2, 3], "val": [0, 1, 0]} + ) return_value = expected.set_index(["a", "b", "c"], inplace=True) assert return_value is None tm.assert_frame_equal(df, expected) @@ -690,11 +692,11 @@ def test_underlying_data_conversion(): pd.set_option("chained_assignment", "raise") # GH 3217 - df = DataFrame(dict(a=[1, 3], b=[np.nan, 2])) + df = DataFrame({"a": [1, 3], "b": [np.nan, 2]}) df["c"] = np.nan df["c"].update(Series(["foo"], index=[0])) - expected = DataFrame(dict(a=[1, 3], b=[np.nan, 2], c=["foo", np.nan])) + expected = DataFrame({"a": [1, 3], "b": [np.nan, 2], "c": ["foo", np.nan]}) tm.assert_frame_equal(df, expected) diff --git a/pandas/tests/series/methods/test_interpolate.py b/pandas/tests/series/methods/test_interpolate.py index 1b05f72f5cf4d..7c64d10675edd 100644 --- a/pandas/tests/series/methods/test_interpolate.py +++ b/pandas/tests/series/methods/test_interpolate.py @@ -37,7 +37,7 @@ def nontemporal_method(request): separately from these non-temporal methods. """ method = request.param - kwargs = dict(order=1) if method in ("spline", "polynomial") else dict() + kwargs = {"order": 1} if method in ("spline", "polynomial") else {} return method, kwargs @@ -67,7 +67,7 @@ def interp_methods_ind(request): 'values' as a parameterization """ method = request.param - kwargs = dict(order=1) if method in ("spline", "polynomial") else dict() + kwargs = {"order": 1} if method in ("spline", "polynomial") else {} return method, kwargs diff --git a/pandas/tests/tseries/holiday/test_holiday.py b/pandas/tests/tseries/holiday/test_holiday.py index a2c146dbd65e8..0fb1da777e357 100644 --- a/pandas/tests/tseries/holiday/test_holiday.py +++ b/pandas/tests/tseries/holiday/test_holiday.py @@ -210,16 +210,16 @@ def test_argument_types(transform): @pytest.mark.parametrize( "name,kwargs", [ - ("One-Time", dict(year=2012, month=5, day=28)), + ("One-Time", {"year": 2012, "month": 5, "day": 28}), ( "Range", - dict( - month=5, - day=28, - start_date=datetime(2012, 1, 1), - end_date=datetime(2012, 12, 31), - offset=DateOffset(weekday=MO(1)), - ), + { + "month": 5, + "day": 28, + "start_date": datetime(2012, 1, 1), + "end_date": datetime(2012, 12, 31), + "offset": DateOffset(weekday=MO(1)), + }, ), ], ) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index fca1316493e85..1ac98247780b7 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -4191,8 +4191,8 @@ class TestDST: # test both basic names and dateutil timezones timezone_utc_offsets = { - "US/Eastern": dict(utc_offset_daylight=-4, utc_offset_standard=-5), - "dateutil/US/Pacific": dict(utc_offset_daylight=-7, utc_offset_standard=-8), + "US/Eastern": {"utc_offset_daylight": -4, "utc_offset_standard": -5}, + "dateutil/US/Pacific": {"utc_offset_daylight": -7, "utc_offset_standard": -8}, } valid_date_offsets_singular = [ "weekday", diff --git a/pandas/tests/tslibs/test_to_offset.py b/pandas/tests/tslibs/test_to_offset.py index 93e5e2c801c09..5b1134ee85e2c 100644 --- a/pandas/tests/tslibs/test_to_offset.py +++ b/pandas/tests/tslibs/test_to_offset.py @@ -131,15 +131,15 @@ def test_to_offset_leading_plus(freqstr, expected): @pytest.mark.parametrize( "kwargs,expected", [ - (dict(days=1, seconds=1), offsets.Second(86401)), - (dict(days=-1, seconds=1), offsets.Second(-86399)), - (dict(hours=1, minutes=10), offsets.Minute(70)), - (dict(hours=1, minutes=-10), offsets.Minute(50)), - (dict(weeks=1), offsets.Day(7)), - (dict(hours=1), offsets.Hour(1)), - (dict(hours=1), to_offset("60min")), - (dict(microseconds=1), offsets.Micro(1)), - (dict(microseconds=0), offsets.Nano(0)), + ({"days": 1, "seconds": 1}, offsets.Second(86401)), + ({"days": -1, "seconds": 1}, offsets.Second(-86399)), + ({"hours": 1, "minutes": 10}, offsets.Minute(70)), + ({"hours": 1, "minutes": -10}, offsets.Minute(50)), + ({"weeks": 1}, offsets.Day(7)), + ({"hours": 1}, offsets.Hour(1)), + ({"hours": 1}, to_offset("60min")), + ({"microseconds": 1}, offsets.Micro(1)), + ({"microseconds": 0}, offsets.Nano(0)), ], ) def test_to_offset_pd_timedelta(kwargs, expected): diff --git a/pandas/tests/util/test_assert_categorical_equal.py b/pandas/tests/util/test_assert_categorical_equal.py index 8957e7a172666..29a0805bceb98 100644 --- a/pandas/tests/util/test_assert_categorical_equal.py +++ b/pandas/tests/util/test_assert_categorical_equal.py @@ -16,7 +16,7 @@ def test_categorical_equal(c): def test_categorical_equal_order_mismatch(check_category_order): c1 = Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4]) c2 = Categorical([1, 2, 3, 4], categories=[4, 3, 2, 1]) - kwargs = dict(check_category_order=check_category_order) + kwargs = {"check_category_order": check_category_order} if check_category_order: msg = """Categorical\\.categories are different diff --git a/pandas/tests/util/test_assert_frame_equal.py b/pandas/tests/util/test_assert_frame_equal.py index d5161ce37494b..40d2763a13489 100644 --- a/pandas/tests/util/test_assert_frame_equal.py +++ b/pandas/tests/util/test_assert_frame_equal.py @@ -120,7 +120,7 @@ def test_frame_equal_shape_mismatch(df1, df2, obj_fixture): ], ) def test_frame_equal_index_dtype_mismatch(df1, df2, msg, check_index_type): - kwargs = dict(check_index_type=check_index_type) + kwargs = {"check_index_type": check_index_type} if check_index_type: with pytest.raises(AssertionError, match=msg): @@ -134,7 +134,7 @@ def test_empty_dtypes(check_dtype): df1 = DataFrame(columns=columns) df2 = DataFrame(columns=columns) - kwargs = dict(check_dtype=check_dtype) + kwargs = {"check_dtype": check_dtype} df1["col1"] = df1["col1"].astype("int64") if check_dtype: diff --git a/pandas/tests/util/test_validate_args.py b/pandas/tests/util/test_validate_args.py index 746d859b3322e..db532480efe07 100644 --- a/pandas/tests/util/test_validate_args.py +++ b/pandas/tests/util/test_validate_args.py @@ -30,7 +30,7 @@ def test_bad_arg_length_max_value_single(): def test_bad_arg_length_max_value_multiple(): args = (None, None) - compat_args = dict(foo=None) + compat_args = {"foo": None} min_fname_arg_count = 2 max_length = len(compat_args) + min_fname_arg_count @@ -61,7 +61,7 @@ def test_not_all_defaults(i): def test_validation(): # No exceptions should be raised. - validate_args(_fname, (None,), 2, dict(out=None)) + validate_args(_fname, (None,), 2, {"out": None}) compat_args = {"axis": 1, "out": None} validate_args(_fname, (1, None), 2, compat_args) diff --git a/pandas/tests/util/test_validate_kwargs.py b/pandas/tests/util/test_validate_kwargs.py index 8fe2a3712bf49..c357affb6203d 100644 --- a/pandas/tests/util/test_validate_kwargs.py +++ b/pandas/tests/util/test_validate_kwargs.py @@ -41,7 +41,7 @@ def test_validation(): # No exceptions should be raised. compat_args = {"f": None, "b": 1, "ba": "s"} - kwargs = dict(f=None, b=1) + kwargs = {"f": None, "b": 1} validate_kwargs(_fname, kwargs, compat_args) diff --git a/pandas/util/_print_versions.py b/pandas/util/_print_versions.py index 72003eeddf5ee..5256cc29d5543 100644 --- a/pandas/util/_print_versions.py +++ b/pandas/util/_print_versions.py @@ -106,7 +106,7 @@ def show_versions(as_json: Union[str, bool] = False) -> None: deps = _get_dependency_info() if as_json: - j = dict(system=sys_info, dependencies=deps) + j = {"system": sys_info, "dependencies": deps} if as_json is True: print(j) From c39a2947cd380f3c19e185714a8e784747d40bc3 Mon Sep 17 00:00:00 2001 From: VirosaLi <2EkF8qUgpNkj> Date: Fri, 27 Nov 2020 12:59:35 -0600 Subject: [PATCH 2/2] fix typos --- pandas/compat/numpy/function.py | 2 +- pandas/tests/arithmetic/test_timedelta64.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/compat/numpy/function.py b/pandas/compat/numpy/function.py index 8db999e79fad8..c47c31fabeb70 100644 --- a/pandas/compat/numpy/function.py +++ b/pandas/compat/numpy/function.py @@ -300,7 +300,7 @@ def validate_take_with_convert(convert, args, kwargs): return convert -TRANSPOSE_DEFAULTS = {"axis": None} +TRANSPOSE_DEFAULTS = {"axes": None} validate_transpose = CompatValidator( TRANSPOSE_DEFAULTS, fname="transpose", method="both", max_fname_arg_count=0 ) diff --git a/pandas/tests/arithmetic/test_timedelta64.py b/pandas/tests/arithmetic/test_timedelta64.py index 22c1951a1bce4..092a3f0d4402f 100644 --- a/pandas/tests/arithmetic/test_timedelta64.py +++ b/pandas/tests/arithmetic/test_timedelta64.py @@ -822,7 +822,7 @@ def test_operators_timedelta64(self): tm.assert_series_equal(rs, xp) assert rs.dtype == "timedelta64[ns]" - df = DataFrame({"A": "v1"}) + df = DataFrame({"A": v1}) td = Series([timedelta(days=i) for i in range(3)]) assert td.dtype == "timedelta64[ns]"