Skip to content

Commit 24a0f1c

Browse files
committed
PEP8 fixes
1 parent 7105f0a commit 24a0f1c

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

pandas/core/reshape/pivot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean',
5050
5151
Examples
5252
--------
53-
>>> df = pd.DataFrame({"A": ["foo", "foo", "foo", "foo", "foo",
54-
... "bar", "bar", "bar", "bar"],
55-
... "B": ["one", "one", "one", "two", "two",
53+
>>> df = pd.DataFrame({"A": ["foo", "foo", "foo", "foo", "foo",
54+
... "bar", "bar", "bar", "bar"],
55+
... "B": ["one", "one", "one", "two", "two",
5656
... "one", "one", "two", "two"],
57-
... "C": ["small", "large", "large", "small",
57+
... "C": ["small", "large", "large", "small",
5858
... "small", "large", "small", "small",
5959
... "large"],
6060
... "D": [1, 2, 2, 3, 3, 4, 5, 6, 7]})
@@ -453,7 +453,7 @@ def crosstab(index, columns, values=None, rownames=None, colnames=None,
453453
>>> b = np.array(["one", "one", "one", "two", "one", "one",
454454
... "one", "two", "two", "two", "one"], dtype=object)
455455
>>> c = np.array(["dull", "dull", "shiny", "dull", "dull", "shiny",
456-
... "shiny", "dull", "shiny", "shiny", "shiny"],
456+
... "shiny", "dull", "shiny", "shiny", "shiny"],
457457
... dtype=object)
458458
459459
>>> pd.crosstab(a, [b, c], rownames=['a'], colnames=['b', 'c'])

pandas/core/reshape/reshape.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ class _Unstacker(object):
4848
>>> import pandas as pd
4949
>>> index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'),
5050
... ('two', 'a'), ('two', 'b')])
51-
>>> s = pd.Series(np.arange(1, 5), index=index)
51+
>>> s = pd.Series(np.arange(1, 5, dtype=np.int64), index=index)
5252
>>> s
5353
one a 1
5454
b 2
5555
two a 3
5656
b 4
57-
dtype: int32
57+
dtype: int64
5858
5959
>>> s.unstack(level=-1)
6060
a b
@@ -988,17 +988,18 @@ def wide_to_long(df, stubnames, i, j, sep="", suffix='\d+'):
988988
... 'B(quarterly)-2011': np.random.rand(3),
989989
... 'X' : np.random.randint(3, size=3)})
990990
>>> df['id'] = df.index
991-
>>> df # doctest: +NORMALIZE_WHITESPACE
992-
A(quarterly)-2010 A(quarterly)-2011 B(quarterly)-2010 B(quarterly)-2011 \
993-
0 0.548814 0.544883 0.437587 0.383442
994-
1 0.715189 0.423655 0.891773 0.791725
995-
2 0.602763 0.645894 0.963663 0.528895
991+
>>> df # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
992+
A(quarterly)-2010 A(quarterly)-2011 B(quarterly)-2010 ...
993+
0 0.548814 0.544883 0.437587 ...
994+
1 0.715189 0.423655 0.891773 ...
995+
2 0.602763 0.645894 0.963663 ...
996996
X id
997997
0 0 0
998998
1 1 1
999999
2 1 2
1000-
1001-
>>> pd.wide_to_long(df, ['A(quarterly)', 'B(quarterly)'], i='id', j='year', sep='-')
1000+
1001+
>>> pd.wide_to_long(df, ['A(quarterly)', 'B(quarterly)'], i='id',
1002+
... j='year', sep='-')
10021003
... # doctest: +NORMALIZE_WHITESPACE
10031004
X A(quarterly) B(quarterly)
10041005
id year
@@ -1012,7 +1013,10 @@ def wide_to_long(df, stubnames, i, j, sep="", suffix='\d+'):
10121013
If we have many columns, we could also use a regex to find our
10131014
stubnames and pass that list on to wide_to_long
10141015
1015-
>>> stubnames = sorted(set([match[0] for match in df.columns.str.findall('[A-B]\(.*\)').values if match != [] ]))
1016+
>>> stubnames = sorted(
1017+
... set([match[0] for match in df.columns.str.findall(
1018+
... r'[A-B]\(.*\)').values if match != [] ])
1019+
... )
10161020
>>> list(stubnames)
10171021
['A(quarterly)', 'B(quarterly)']
10181022
@@ -1133,7 +1137,7 @@ def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False,
11331137
1 0 1 0
11341138
2 0 0 1
11351139
1136-
>>> df = pd.DataFrame({'A': ['a', 'b', 'a'], 'B': ['b', 'a', 'c'],
1140+
>>> df = pd.DataFrame({'A': ['a', 'b', 'a'], 'B': ['b', 'a', 'c'],
11371141
... 'C': [1, 2, 3]})
11381142
11391143
>>> pd.get_dummies(df, prefix=['col1', 'col2'])

pandas/core/reshape/tile.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,18 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3,
7575
Examples
7676
--------
7777
>>> pd.cut(np.array([.2, 1.4, 2.5, 6.2, 9.7, 2.1]), 3, retbins=True)
78-
([(0.19, 3.367], (0.19, 3.367], (0.19, 3.367], (3.367, 6.533], (6.533, 9.7], (0.19, 3.367]]
79-
Categories (3, interval[float64]): [(0.19, 3.367] < (3.367, 6.533] < (6.533, 9.7]], array([ 0.1905 , 3.36666667, 6.53333333, 9.7 ]))
78+
... # doctest: +ELLIPSIS
79+
([(0.19, 3.367], (0.19, 3.367], (0.19, 3.367], (3.367, 6.533], ...
80+
Categories (3, interval[float64]): [(0.19, 3.367] < (3.367, 6.533] ...
8081
8182
>>> pd.cut(np.array([.2, 1.4, 2.5, 6.2, 9.7, 2.1]),
82-
... 3, labels=["good","medium","bad"])
83+
... 3, labels=["good", "medium", "bad"])
8384
... # doctest: +SKIP
8485
[good, good, good, medium, bad, good]
8586
Categories (3, object): [good < medium < bad]
8687
8788
>>> pd.cut(np.ones(5), 4, labels=False)
88-
array([1, 1, 1, 1, 1], dtype=int64)
89+
array([1, 1, 1, 1, 1])
8990
"""
9091
# NOTE: this binning code is changed a bit from histogram for var(x) == 0
9192

@@ -181,15 +182,17 @@ def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'):
181182
Examples
182183
--------
183184
>>> pd.qcut(range(5), 4)
185+
... # doctest: +ELLIPSIS
184186
[(-0.001, 1.0], (-0.001, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]]
185-
Categories (4, interval[float64]): [(-0.001, 1.0] < (1.0, 2.0] < (2.0, 3.0] < (3.0, 4.0]]
187+
Categories (4, interval[float64]): [(-0.001, 1.0] < (1.0, 2.0] ...
186188
187-
>>> pd.qcut(range(5), 3, labels=["good","medium","bad"])
189+
>>> pd.qcut(range(5), 3, labels=["good", "medium", "bad"])
190+
... # doctest: +SKIP
188191
[good, good, medium, bad, bad]
189192
Categories (3, object): [good < medium < bad]
190193
191194
>>> pd.qcut(range(5), 4, labels=False)
192-
array([0, 0, 1, 2, 3], dtype=int64)
195+
array([0, 0, 1, 2, 3])
193196
"""
194197
x_is_series, series_index, name, x = _preprocess_for_cut(x)
195198

0 commit comments

Comments
 (0)