Skip to content

Commit f1c5386

Browse files
committed
Merge pull request #7461 from toddrjen/pep8
nanops pep8 fixes
2 parents 60119ce + 95f0095 commit f1c5386

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

pandas/core/nanops.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
from pandas import compat
21
import sys
32
import itertools
43
import functools
54

65
import numpy as np
76

8-
from pandas.core.common import isnull, notnull, _values_from_object, is_float
9-
import pandas.core.common as com
10-
import pandas.lib as lib
11-
import pandas.algos as algos
12-
import pandas.hashtable as _hash
13-
import pandas.tslib as tslib
14-
15-
from pandas.compat import builtins
16-
17-
187
try:
198
import bottleneck as bn
209
_USE_BOTTLENECK = True
2110
except ImportError: # pragma: no cover
2211
_USE_BOTTLENECK = False
2312

13+
import pandas.core.common as com
14+
import pandas.hashtable as _hash
15+
from pandas import compat, lib, algos, tslib
16+
from pandas.compat import builtins
17+
from pandas.core.common import isnull, notnull, _values_from_object, is_float
18+
2419

2520
class disallow(object):
2621

@@ -75,7 +70,8 @@ def f(values, axis=None, skipna=True, **kwds):
7570
result.fill(0)
7671
return result
7772

78-
if _USE_BOTTLENECK and skipna and _bn_ok_dtype(values.dtype, bn_name):
73+
if _USE_BOTTLENECK and skipna and _bn_ok_dtype(values.dtype,
74+
bn_name):
7975
result = bn_func(values, axis=axis, **kwds)
8076

8177
# prefer to treat inf/-inf as NA, but must compute the func
@@ -94,7 +90,8 @@ def f(values, axis=None, skipna=True, **kwds):
9490

9591
def _bn_ok_dtype(dt, name):
9692
# Bottleneck chokes on datetime64
97-
if dt != np.object_ and not issubclass(dt.type, (np.datetime64, np.timedelta64)):
93+
if dt != np.object_ and not issubclass(dt.type, (np.datetime64,
94+
np.timedelta64)):
9895

9996
# bottleneck does not properly upcast during the sum
10097
# so can overflow
@@ -179,8 +176,9 @@ def _get_values(values, skipna, fill_value=None, fill_value_typ=None,
179176

180177
# return a platform independent precision dtype
181178
dtype_max = dtype
182-
if dtype.kind == 'i' and not issubclass(
183-
dtype.type, (np.bool, np.datetime64, np.timedelta64)):
179+
if dtype.kind == 'i' and not issubclass(dtype.type, (np.bool,
180+
np.datetime64,
181+
np.timedelta64)):
184182
dtype_max = np.int64
185183
elif dtype.kind in ['b'] or issubclass(dtype.type, np.bool):
186184
dtype_max = np.int64
@@ -251,7 +249,7 @@ def nanall(values, axis=None, skipna=True):
251249
@bottleneck_switch(zero_value=0)
252250
def nansum(values, axis=None, skipna=True):
253251
values, mask, dtype, dtype_max = _get_values(values, skipna, 0)
254-
the_sum = values.sum(axis,dtype=dtype_max)
252+
the_sum = values.sum(axis, dtype=dtype_max)
255253
the_sum = _maybe_null_out(the_sum, axis, mask)
256254

257255
return _wrap_results(the_sum, dtype)
@@ -365,7 +363,8 @@ def nansem(values, axis=None, skipna=True, ddof=1):
365363

366364
@bottleneck_switch()
367365
def nanmin(values, axis=None, skipna=True):
368-
values, mask, dtype, dtype_max = _get_values(values, skipna, fill_value_typ='+inf')
366+
values, mask, dtype, dtype_max = _get_values(values, skipna,
367+
fill_value_typ='+inf')
369368

370369
# numpy 1.6.1 workaround in Python 3.x
371370
if (values.dtype == np.object_ and compat.PY3):
@@ -381,7 +380,7 @@ def nanmin(values, axis=None, skipna=True):
381380
if ((axis is not None and values.shape[axis] == 0)
382381
or values.size == 0):
383382
try:
384-
result = com.ensure_float(values.sum(axis,dtype=dtype_max))
383+
result = com.ensure_float(values.sum(axis, dtype=dtype_max))
385384
result.fill(np.nan)
386385
except:
387386
result = np.nan
@@ -394,7 +393,8 @@ def nanmin(values, axis=None, skipna=True):
394393

395394
@bottleneck_switch()
396395
def nanmax(values, axis=None, skipna=True):
397-
values, mask, dtype, dtype_max = _get_values(values, skipna, fill_value_typ='-inf')
396+
values, mask, dtype, dtype_max = _get_values(values, skipna,
397+
fill_value_typ='-inf')
398398

399399
# numpy 1.6.1 workaround in Python 3.x
400400
if (values.dtype == np.object_ and compat.PY3):
@@ -427,7 +427,7 @@ def nanargmax(values, axis=None, skipna=True):
427427
Returns -1 in the NA case
428428
"""
429429
values, mask, dtype, _ = _get_values(values, skipna, fill_value_typ='-inf',
430-
isfinite=True)
430+
isfinite=True)
431431
result = values.argmax(axis)
432432
result = _maybe_arg_null_out(result, axis, mask, skipna)
433433
return result
@@ -438,7 +438,7 @@ def nanargmin(values, axis=None, skipna=True):
438438
Returns -1 in the NA case
439439
"""
440440
values, mask, dtype, _ = _get_values(values, skipna, fill_value_typ='+inf',
441-
isfinite=True)
441+
isfinite=True)
442442
result = values.argmin(axis)
443443
result = _maybe_arg_null_out(result, axis, mask, skipna)
444444
return result

0 commit comments

Comments
 (0)