Skip to content

Commit f1d1e20

Browse files
committed
Run black
1 parent 9f3b88e commit f1d1e20

File tree

3 files changed

+97
-71
lines changed

3 files changed

+97
-71
lines changed

pandas/tests/reshape/concat/test_datetimes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ def test_concat_tz_series_with_datetimelike(self):
374374
def test_concat_tz_frame(self):
375375
df2 = DataFrame(
376376
{
377-
'A':Timestamp("20130102", tz="US/Eastern"),
378-
'B':Timestamp("20130603", tz="CET"),
377+
"A": Timestamp("20130102", tz="US/Eastern"),
378+
"B": Timestamp("20130603", tz="CET"),
379379
},
380380
index=range(5),
381381
)
@@ -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({'time':[ts1]})
395-
df2 = DataFrame({'time':[ts2]})
396-
df3 = DataFrame({'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({'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({'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({'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

Lines changed: 23 additions & 23 deletions
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-
{'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"},
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-
{'left_index':True, 'right_index':True},
479-
{'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 = {'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 = {'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-
{'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"},
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,17 +1999,17 @@ 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, {'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]),
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]),
20132013
("a", "a", {}, ["a_x", "a_y"]),
20142014
(0, 0, {}, ["0_x", "0_y"]),
20152015
],

pandas/tests/reshape/merge/test_multi.py

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def right():
3737
def left_multi():
3838
return DataFrame(
3939
{
40-
'Origin':["A", "A", "B", "B", "C"],
41-
'Destination':["A", "B", "A", "C", "A"],
42-
'Period':["AM", "AM", "IP", "AM", "OP"],
43-
'TripPurp':["hbw", "nhb", "hbo", "nhb", "hbw"],
44-
'Trips':[1987, 3647, 2470, 4296, 4444],
40+
"Origin": ["A", "A", "B", "B", "C"],
41+
"Destination": ["A", "B", "A", "C", "A"],
42+
"Period": ["AM", "AM", "IP", "AM", "OP"],
43+
"TripPurp": ["hbw", "nhb", "hbo", "nhb", "hbw"],
44+
"Trips": [1987, 3647, 2470, 4296, 4444],
4545
},
4646
columns=["Origin", "Destination", "Period", "TripPurp", "Trips"],
4747
).set_index(["Origin", "Destination", "Period", "TripPurp"])
@@ -51,11 +51,11 @@ def left_multi():
5151
def right_multi():
5252
return DataFrame(
5353
{
54-
'Origin':["A", "A", "B", "B", "C", "C", "E"],
55-
'Destination':["A", "B", "A", "B", "A", "B", "F"],
56-
'Period':["AM", "AM", "IP", "AM", "OP", "IP", "AM"],
57-
'LinkType':["a", "b", "c", "b", "a", "b", "a"],
58-
'Distance':[100, 80, 90, 80, 75, 35, 55],
54+
"Origin": ["A", "A", "B", "B", "C", "C", "E"],
55+
"Destination": ["A", "B", "A", "B", "A", "B", "F"],
56+
"Period": ["AM", "AM", "IP", "AM", "OP", "IP", "AM"],
57+
"LinkType": ["a", "b", "c", "b", "a", "b", "a"],
58+
"Distance": [100, 80, 90, 80, 75, 35, 55],
5959
},
6060
columns=["Origin", "Destination", "Period", "LinkType", "Distance"],
6161
).set_index(["Origin", "Destination", "Period", "LinkType"])
@@ -534,16 +534,16 @@ def test_join_multi_levels(self):
534534
# merge multi-levels
535535
household = DataFrame(
536536
{
537-
'household_id':[1, 2, 3],
538-
'male':[0, 1, 0],
539-
'wealth':[196087.3, 316478.7, 294750],
537+
"household_id": [1, 2, 3],
538+
"male": [0, 1, 0],
539+
"wealth": [196087.3, 316478.7, 294750],
540540
},
541541
columns=["household_id", "male", "wealth"],
542542
).set_index("household_id")
543543
portfolio = DataFrame(
544544
{
545-
'household_id':[1, 2, 2, 3, 3, 3, 4],
546-
'asset_id':[
545+
"household_id": [1, 2, 2, 3, 3, 3, 4],
546+
"asset_id": [
547547
"nl0000301109",
548548
"nl0000289783",
549549
"gb00b03mlx29",
@@ -552,7 +552,7 @@ def test_join_multi_levels(self):
552552
"nl0000289965",
553553
np.nan,
554554
],
555-
'name':[
555+
"name": [
556556
"ABN Amro",
557557
"Robeco",
558558
"Royal Dutch Shell",
@@ -561,27 +561,34 @@ def test_join_multi_levels(self):
561561
"Postbank BioTech Fonds",
562562
np.nan,
563563
],
564-
'share':[1.0, 0.4, 0.6, 0.15, 0.6, 0.25, 1.0],
564+
"share": [1.0, 0.4, 0.6, 0.15, 0.6, 0.25, 1.0],
565565
},
566566
columns=["household_id", "asset_id", "name", "share"],
567567
).set_index(["household_id", "asset_id"])
568568
result = household.join(portfolio, how="inner")
569569
expected = (
570570
DataFrame(
571571
{
572-
'male':[0, 1, 1, 0, 0, 0],
573-
'wealth':[196087.3, 316478.7, 316478.7, 294750.0, 294750.0, 294750.0],
574-
'name':[
572+
"male": [0, 1, 1, 0, 0, 0],
573+
"wealth": [
574+
196087.3,
575+
316478.7,
576+
316478.7,
577+
294750.0,
578+
294750.0,
579+
294750.0,
580+
],
581+
"name": [
575582
"ABN Amro",
576583
"Robeco",
577584
"Royal Dutch Shell",
578585
"Royal Dutch Shell",
579586
"AAB Eastern Europe Equity Fund",
580587
"Postbank BioTech Fonds",
581588
],
582-
'share':[1.00, 0.40, 0.60, 0.15, 0.60, 0.25],
583-
'household_id':[1, 2, 2, 3, 3, 3],
584-
'asset_id':[
589+
"share": [1.00, 0.40, 0.60, 0.15, 0.60, 0.25],
590+
"household_id": [1, 2, 2, 3, 3, 3],
591+
"asset_id": [
585592
"nl0000301109",
586593
"nl0000289783",
587594
"gb00b03mlx29",
@@ -611,7 +618,7 @@ def test_join_multi_levels(self):
611618
expected,
612619
(
613620
DataFrame(
614-
{'share':[1.00]},
621+
{"share": [1.00]},
615622
index=MultiIndex.from_tuples(
616623
[(4, np.nan)], names=["household_id", "asset_id"]
617624
),
@@ -643,8 +650,8 @@ def test_join_multi_levels2(self):
643650
# GH6360
644651
household = DataFrame(
645652
{
646-
'household_id':[1, 2, 2, 3, 3, 3, 4],
647-
'asset_id':[
653+
"household_id": [1, 2, 2, 3, 3, 3, 4],
654+
"asset_id": [
648655
"nl0000301109",
649656
"nl0000301109",
650657
"gb00b03mlx29",
@@ -653,30 +660,36 @@ def test_join_multi_levels2(self):
653660
"nl0000289965",
654661
np.nan,
655662
],
656-
'share':[1.0, 0.4, 0.6, 0.15, 0.6, 0.25, 1.0],
663+
"share": [1.0, 0.4, 0.6, 0.15, 0.6, 0.25, 1.0],
657664
},
658665
columns=["household_id", "asset_id", "share"],
659666
).set_index(["household_id", "asset_id"])
660667

661668
log_return = DataFrame(
662669
{
663-
'asset_id':[
670+
"asset_id": [
664671
"gb00b03mlx29",
665672
"gb00b03mlx29",
666673
"gb00b03mlx29",
667674
"lu0197800237",
668675
"lu0197800237",
669676
],
670-
't':[233, 234, 235, 180, 181],
671-
'log_return':[0.09604978, -0.06524096, 0.03532373, 0.03025441, 0.036997],
677+
"t": [233, 234, 235, 180, 181],
678+
"log_return": [
679+
0.09604978,
680+
-0.06524096,
681+
0.03532373,
682+
0.03025441,
683+
0.036997,
684+
],
672685
}
673686
).set_index(["asset_id", "t"])
674687

675688
expected = (
676689
DataFrame(
677690
{
678-
'household_id':[2, 2, 2, 3, 3, 3, 3, 3],
679-
'asset_id':[
691+
"household_id": [2, 2, 2, 3, 3, 3, 3, 3],
692+
"asset_id": [
680693
"gb00b03mlx29",
681694
"gb00b03mlx29",
682695
"gb00b03mlx29",
@@ -686,9 +699,9 @@ def test_join_multi_levels2(self):
686699
"lu0197800237",
687700
"lu0197800237",
688701
],
689-
't':[233, 234, 235, 233, 234, 235, 180, 181],
690-
'share':[0.6, 0.6, 0.6, 0.15, 0.15, 0.15, 0.6, 0.6],
691-
'log_return':[
702+
"t": [233, 234, 235, 233, 234, 235, 180, 181],
703+
"share": [0.6, 0.6, 0.6, 0.15, 0.15, 0.15, 0.6, 0.6],
704+
"log_return": [
692705
0.09604978,
693706
-0.06524096,
694707
0.03532373,
@@ -716,8 +729,8 @@ def test_join_multi_levels2(self):
716729
expected = (
717730
DataFrame(
718731
{
719-
'household_id':[1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4],
720-
'asset_id':[
732+
"household_id": [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4],
733+
"asset_id": [
721734
"nl0000301109",
722735
"nl0000301109",
723736
"gb00b03mlx29",
@@ -731,8 +744,21 @@ def test_join_multi_levels2(self):
731744
"nl0000289965",
732745
None,
733746
],
734-
't':[None, None, 233, 234, 235, 233, 234, 235, 180, 181, None, None],
735-
'share':[
747+
"t": [
748+
None,
749+
None,
750+
233,
751+
234,
752+
235,
753+
233,
754+
234,
755+
235,
756+
180,
757+
181,
758+
None,
759+
None,
760+
],
761+
"share": [
736762
1.0,
737763
0.4,
738764
0.6,
@@ -746,7 +772,7 @@ def test_join_multi_levels2(self):
746772
0.25,
747773
1.0,
748774
],
749-
'log_return':[
775+
"log_return": [
750776
None,
751777
None,
752778
0.09604978,

0 commit comments

Comments
 (0)