Skip to content

Rewrite dict literal for files in tests/reshape/ #38180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions pandas/tests/reshape/concat/test_datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ def test_concat_tz_series_with_datetimelike(self):

def test_concat_tz_frame(self):
df2 = DataFrame(
dict(
A=Timestamp("20130102", tz="US/Eastern"),
B=Timestamp("20130603", tz="CET"),
),
{
"A": Timestamp("20130102", tz="US/Eastern"),
"B": Timestamp("20130603", tz="CET"),
},
index=range(5),
)

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

df1 = DataFrame(dict(time=[ts1]))
df2 = DataFrame(dict(time=[ts2]))
df3 = DataFrame(dict(time=[ts3]))
df1 = DataFrame({"time": [ts1]})
df2 = DataFrame({"time": [ts2]})
df3 = DataFrame({"time": [ts3]})

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

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

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

def test_concat_multiindex_with_tz(self):
Expand Down
50 changes: 25 additions & 25 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ def test_left_merge_empty_dataframe(self):
@pytest.mark.parametrize(
"kwarg",
[
dict(left_index=True, right_index=True),
dict(left_index=True, right_on="x"),
dict(left_on="a", right_index=True),
dict(left_on="a", right_on="x"),
{"left_index": True, "right_index": True},
{"left_index": True, "right_on": "x"},
{"left_on": "a", "right_index": True},
{"left_on": "a", "right_on": "x"},
],
)
def test_merge_left_empty_right_empty(self, join_type, kwarg):
Expand Down Expand Up @@ -475,18 +475,18 @@ def check2(exp, kwarg):
tm.assert_frame_equal(result, exp)

for kwarg in [
dict(left_index=True, right_index=True),
dict(left_index=True, right_on="x"),
{"left_index": True, "right_index": True},
{"left_index": True, "right_on": "x"},
]:
check1(exp_in, kwarg)
check2(exp_out, kwarg)

kwarg = dict(left_on="a", right_index=True)
kwarg = {"left_on": "a", "right_index": True}
check1(exp_in, kwarg)
exp_out["a"] = [0, 1, 2]
check2(exp_out, kwarg)

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

for kwarg in [
dict(left_index=True, right_index=True),
dict(left_index=True, right_on="x"),
dict(left_on="a", right_index=True),
dict(left_on="a", right_on="x"),
{"left_index": True, "right_index": True},
{"left_index": True, "right_on": "x"},
{"left_on": "a", "right_index": True},
{"left_on": "a", "right_on": "x"},
]:
check1(exp_in, kwarg)
check2(exp_out, kwarg)
Expand Down Expand Up @@ -1999,19 +1999,19 @@ def test_merge_series(on, left_on, right_on, left_index, right_index, nm):
@pytest.mark.parametrize(
"col1, col2, kwargs, expected_cols",
[
(0, 0, dict(suffixes=("", "_dup")), ["0", "0_dup"]),
(0, 0, dict(suffixes=(None, "_dup")), [0, "0_dup"]),
(0, 0, dict(suffixes=("_x", "_y")), ["0_x", "0_y"]),
(0, 0, dict(suffixes=["_x", "_y"]), ["0_x", "0_y"]),
("a", 0, dict(suffixes=(None, "_y")), ["a", 0]),
(0.0, 0.0, dict(suffixes=("_x", None)), ["0.0_x", 0.0]),
("b", "b", dict(suffixes=(None, "_y")), ["b", "b_y"]),
("a", "a", dict(suffixes=("_x", None)), ["a_x", "a"]),
("a", "b", dict(suffixes=("_x", None)), ["a", "b"]),
("a", "a", dict(suffixes=(None, "_x")), ["a", "a_x"]),
(0, 0, dict(suffixes=("_a", None)), ["0_a", 0]),
("a", "a", dict(), ["a_x", "a_y"]),
(0, 0, dict(), ["0_x", "0_y"]),
(0, 0, {"suffixes": ("", "_dup")}, ["0", "0_dup"]),
(0, 0, {"suffixes": (None, "_dup")}, [0, "0_dup"]),
(0, 0, {"suffixes": ("_x", "_y")}, ["0_x", "0_y"]),
(0, 0, {"suffixes": ["_x", "_y"]}, ["0_x", "0_y"]),
("a", 0, {"suffixes": (None, "_y")}, ["a", 0]),
(0.0, 0.0, {"suffixes": ("_x", None)}, ["0.0_x", 0.0]),
("b", "b", {"suffixes": (None, "_y")}, ["b", "b_y"]),
("a", "a", {"suffixes": ("_x", None)}, ["a_x", "a"]),
("a", "b", {"suffixes": ("_x", None)}, ["a", "b"]),
("a", "a", {"suffixes": (None, "_x")}, ["a", "a_x"]),
(0, 0, {"suffixes": ("_a", None)}, ["0_a", 0]),
("a", "a", {}, ["a_x", "a_y"]),
(0, 0, {}, ["0_x", "0_y"]),
],
)
def test_merge_suffix(col1, col2, kwargs, expected_cols):
Expand Down
Loading