Skip to content

Commit ff78a02

Browse files
authored
Rewrite dict literal for files in tests/reshape/ (#38180)
1 parent c479d93 commit ff78a02

File tree

3 files changed

+119
-93
lines changed

3 files changed

+119
-93
lines changed

pandas/tests/reshape/concat/test_datetimes.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ def test_concat_tz_series_with_datetimelike(self):
373373

374374
def test_concat_tz_frame(self):
375375
df2 = DataFrame(
376-
dict(
377-
A=Timestamp("20130102", tz="US/Eastern"),
378-
B=Timestamp("20130603", tz="CET"),
379-
),
376+
{
377+
"A": Timestamp("20130102", tz="US/Eastern"),
378+
"B": Timestamp("20130603", tz="CET"),
379+
},
380380
index=range(5),
381381
)
382382

@@ -391,20 +391,20 @@ def test_concat_multiple_tzs(self):
391391
ts2 = Timestamp("2015-01-01", tz="UTC")
392392
ts3 = Timestamp("2015-01-01", tz="EST")
393393

394-
df1 = DataFrame(dict(time=[ts1]))
395-
df2 = DataFrame(dict(time=[ts2]))
396-
df3 = DataFrame(dict(time=[ts3]))
394+
df1 = DataFrame({"time": [ts1]})
395+
df2 = DataFrame({"time": [ts2]})
396+
df3 = DataFrame({"time": [ts3]})
397397

398398
results = pd.concat([df1, df2]).reset_index(drop=True)
399-
expected = DataFrame(dict(time=[ts1, ts2]), dtype=object)
399+
expected = DataFrame({"time": [ts1, ts2]}, dtype=object)
400400
tm.assert_frame_equal(results, expected)
401401

402402
results = pd.concat([df1, df3]).reset_index(drop=True)
403-
expected = DataFrame(dict(time=[ts1, ts3]), dtype=object)
403+
expected = DataFrame({"time": [ts1, ts3]}, dtype=object)
404404
tm.assert_frame_equal(results, expected)
405405

406406
results = pd.concat([df2, df3]).reset_index(drop=True)
407-
expected = DataFrame(dict(time=[ts2, ts3]))
407+
expected = DataFrame({"time": [ts2, ts3]})
408408
tm.assert_frame_equal(results, expected)
409409

410410
def test_concat_multiindex_with_tz(self):

pandas/tests/reshape/merge/test_merge.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,10 @@ def test_left_merge_empty_dataframe(self):
422422
@pytest.mark.parametrize(
423423
"kwarg",
424424
[
425-
dict(left_index=True, right_index=True),
426-
dict(left_index=True, right_on="x"),
427-
dict(left_on="a", right_index=True),
428-
dict(left_on="a", right_on="x"),
425+
{"left_index": True, "right_index": True},
426+
{"left_index": True, "right_on": "x"},
427+
{"left_on": "a", "right_index": True},
428+
{"left_on": "a", "right_on": "x"},
429429
],
430430
)
431431
def test_merge_left_empty_right_empty(self, join_type, kwarg):
@@ -475,18 +475,18 @@ def check2(exp, kwarg):
475475
tm.assert_frame_equal(result, exp)
476476

477477
for kwarg in [
478-
dict(left_index=True, right_index=True),
479-
dict(left_index=True, right_on="x"),
478+
{"left_index": True, "right_index": True},
479+
{"left_index": True, "right_on": "x"},
480480
]:
481481
check1(exp_in, kwarg)
482482
check2(exp_out, kwarg)
483483

484-
kwarg = dict(left_on="a", right_index=True)
484+
kwarg = {"left_on": "a", "right_index": True}
485485
check1(exp_in, kwarg)
486486
exp_out["a"] = [0, 1, 2]
487487
check2(exp_out, kwarg)
488488

489-
kwarg = dict(left_on="a", right_on="x")
489+
kwarg = {"left_on": "a", "right_on": "x"}
490490
check1(exp_in, kwarg)
491491
exp_out["a"] = np.array([np.nan] * 3, dtype=object)
492492
check2(exp_out, kwarg)
@@ -524,10 +524,10 @@ def check2(exp, kwarg):
524524
tm.assert_frame_equal(result, exp)
525525

526526
for kwarg in [
527-
dict(left_index=True, right_index=True),
528-
dict(left_index=True, right_on="x"),
529-
dict(left_on="a", right_index=True),
530-
dict(left_on="a", right_on="x"),
527+
{"left_index": True, "right_index": True},
528+
{"left_index": True, "right_on": "x"},
529+
{"left_on": "a", "right_index": True},
530+
{"left_on": "a", "right_on": "x"},
531531
]:
532532
check1(exp_in, kwarg)
533533
check2(exp_out, kwarg)
@@ -1999,19 +1999,19 @@ def test_merge_series(on, left_on, right_on, left_index, right_index, nm):
19991999
@pytest.mark.parametrize(
20002000
"col1, col2, kwargs, expected_cols",
20012001
[
2002-
(0, 0, dict(suffixes=("", "_dup")), ["0", "0_dup"]),
2003-
(0, 0, dict(suffixes=(None, "_dup")), [0, "0_dup"]),
2004-
(0, 0, dict(suffixes=("_x", "_y")), ["0_x", "0_y"]),
2005-
(0, 0, dict(suffixes=["_x", "_y"]), ["0_x", "0_y"]),
2006-
("a", 0, dict(suffixes=(None, "_y")), ["a", 0]),
2007-
(0.0, 0.0, dict(suffixes=("_x", None)), ["0.0_x", 0.0]),
2008-
("b", "b", dict(suffixes=(None, "_y")), ["b", "b_y"]),
2009-
("a", "a", dict(suffixes=("_x", None)), ["a_x", "a"]),
2010-
("a", "b", dict(suffixes=("_x", None)), ["a", "b"]),
2011-
("a", "a", dict(suffixes=(None, "_x")), ["a", "a_x"]),
2012-
(0, 0, dict(suffixes=("_a", None)), ["0_a", 0]),
2013-
("a", "a", dict(), ["a_x", "a_y"]),
2014-
(0, 0, dict(), ["0_x", "0_y"]),
2002+
(0, 0, {"suffixes": ("", "_dup")}, ["0", "0_dup"]),
2003+
(0, 0, {"suffixes": (None, "_dup")}, [0, "0_dup"]),
2004+
(0, 0, {"suffixes": ("_x", "_y")}, ["0_x", "0_y"]),
2005+
(0, 0, {"suffixes": ["_x", "_y"]}, ["0_x", "0_y"]),
2006+
("a", 0, {"suffixes": (None, "_y")}, ["a", 0]),
2007+
(0.0, 0.0, {"suffixes": ("_x", None)}, ["0.0_x", 0.0]),
2008+
("b", "b", {"suffixes": (None, "_y")}, ["b", "b_y"]),
2009+
("a", "a", {"suffixes": ("_x", None)}, ["a_x", "a"]),
2010+
("a", "b", {"suffixes": ("_x", None)}, ["a", "b"]),
2011+
("a", "a", {"suffixes": (None, "_x")}, ["a", "a_x"]),
2012+
(0, 0, {"suffixes": ("_a", None)}, ["0_a", 0]),
2013+
("a", "a", {}, ["a_x", "a_y"]),
2014+
(0, 0, {}, ["0_x", "0_y"]),
20152015
],
20162016
)
20172017
def test_merge_suffix(col1, col2, kwargs, expected_cols):

0 commit comments

Comments
 (0)