Skip to content

Commit 0c58a82

Browse files
mroeschkejreback
authored andcommitted
CLN: Remove unused variables (#21986)
1 parent e8e078f commit 0c58a82

File tree

19 files changed

+38
-30
lines changed

19 files changed

+38
-30
lines changed

pandas/core/arrays/categorical.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
348348
" or `ordered`.")
349349

350350
categories = dtype.categories
351-
ordered = dtype.ordered
352351

353352
elif is_categorical(values):
354353
# If no "dtype" was passed, use the one from "values", but honor

pandas/core/arrays/interval.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ def from_tuples(cls, data, closed='right', copy=False, dtype=None):
401401
msg = ('{name}.from_tuples received an invalid '
402402
'item, {tpl}').format(name=name, tpl=d)
403403
raise TypeError(msg)
404-
lhs, rhs = d
405404
left.append(lhs)
406405
right.append(rhs)
407406

pandas/core/generic.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,8 @@ def rename(self, *args, **kwargs):
10841084
level = kwargs.pop('level', None)
10851085
axis = kwargs.pop('axis', None)
10861086
if axis is not None:
1087-
axis = self._get_axis_number(axis)
1087+
# Validate the axis
1088+
self._get_axis_number(axis)
10881089

10891090
if kwargs:
10901091
raise TypeError('rename() got an unexpected keyword '
@@ -5299,6 +5300,12 @@ def __copy__(self, deep=True):
52995300
return self.copy(deep=deep)
53005301

53015302
def __deepcopy__(self, memo=None):
5303+
"""
5304+
Parameters
5305+
----------
5306+
memo, default None
5307+
Standard signature. Unused
5308+
"""
53025309
if memo is None:
53035310
memo = {}
53045311
return self.copy(deep=True)

pandas/core/groupby/ops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ def _transform(self, result, values, comp_ids, transform_func,
582582
elif values.ndim > 2:
583583
for i, chunk in enumerate(values.transpose(2, 0, 1)):
584584

585-
chunk = chunk.squeeze()
586585
transform_func(result[:, :, i], values,
587586
comp_ids, is_datetimelike, **kwargs)
588587
else:

pandas/core/indexes/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,12 @@ def __copy__(self, **kwargs):
993993
return self.copy(**kwargs)
994994

995995
def __deepcopy__(self, memo=None):
996+
"""
997+
Parameters
998+
----------
999+
memo, default None
1000+
Standard signature. Unused
1001+
"""
9961002
if memo is None:
9971003
memo = {}
9981004
return self.copy(deep=True)

pandas/core/indexes/category.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _create_from_codes(self, codes, categories=None, ordered=None,
133133
if name is None:
134134
name = self.name
135135
cat = Categorical.from_codes(codes, categories=categories,
136-
ordered=self.ordered)
136+
ordered=ordered)
137137
return CategoricalIndex(cat, name=name)
138138

139139
@classmethod

pandas/core/indexes/interval.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ def _format_data(self, name=None):
939939
summary = '[{head} ... {tail}]'.format(
940940
head=', '.join(head), tail=', '.join(tail))
941941
else:
942-
head = []
943942
tail = [formatter(x) for x in self]
944943
summary = '[{tail}]'.format(tail=', '.join(tail))
945944

pandas/core/internals/blocks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ def take_nd(self, indexer, axis, new_mgr_locs=None, fill_tuple=None):
12481248
if fill_tuple is None:
12491249
fill_value = self.fill_value
12501250
new_values = algos.take_nd(values, indexer, axis=axis,
1251-
allow_fill=False)
1251+
allow_fill=False, fill_value=fill_value)
12521252
else:
12531253
fill_value = fill_tuple[0]
12541254
new_values = algos.take_nd(values, indexer, axis=axis,
@@ -2699,7 +2699,6 @@ def _try_coerce_args(self, values, other):
26992699

27002700
values_mask = isna(values)
27012701
values = values.view('i8')
2702-
other_mask = False
27032702

27042703
if isinstance(other, bool):
27052704
raise TypeError
@@ -2872,11 +2871,9 @@ def _try_coerce_args(self, values, other):
28722871
values_mask = _block_shape(isna(values), ndim=self.ndim)
28732872
# asi8 is a view, needs copy
28742873
values = _block_shape(values.asi8, ndim=self.ndim)
2875-
other_mask = False
28762874

28772875
if isinstance(other, ABCSeries):
28782876
other = self._holder(other)
2879-
other_mask = isna(other)
28802877

28812878
if isinstance(other, bool):
28822879
raise TypeError

pandas/core/nanops.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ def nanvar(values, axis=None, skipna=True, ddof=1):
479479

480480
@disallow('M8', 'm8')
481481
def nansem(values, axis=None, skipna=True, ddof=1):
482-
var = nanvar(values, axis, skipna, ddof=ddof)
482+
# This checks if non-numeric-like data is passed with numeric_only=False
483+
# and raises a TypeError otherwise
484+
nanvar(values, axis, skipna, ddof=ddof)
483485

484486
mask = isna(values)
485487
if not is_float_dtype(values.dtype):
@@ -635,7 +637,6 @@ def nankurt(values, axis=None, skipna=True):
635637
adj = 3 * (count - 1) ** 2 / ((count - 2) * (count - 3))
636638
numer = count * (count + 1) * (count - 1) * m4
637639
denom = (count - 2) * (count - 3) * m2**2
638-
result = numer / denom - adj
639640

640641
# floating point error
641642
#

pandas/core/series.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,6 @@ def dot(self, other):
20522052
lvals = left.values
20532053
rvals = right.values
20542054
else:
2055-
left = self
20562055
lvals = self.values
20572056
rvals = np.asarray(other)
20582057
if lvals.shape[0] != rvals.shape[0]:
@@ -2480,7 +2479,8 @@ def sort_values(self, axis=0, ascending=True, inplace=False,
24802479
dtype: object
24812480
"""
24822481
inplace = validate_bool_kwarg(inplace, 'inplace')
2483-
axis = self._get_axis_number(axis)
2482+
# Validate the axis parameter
2483+
self._get_axis_number(axis)
24842484

24852485
# GH 5856/5853
24862486
if inplace and self._is_cached:
@@ -2652,7 +2652,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
26522652
# TODO: this can be combined with DataFrame.sort_index impl as
26532653
# almost identical
26542654
inplace = validate_bool_kwarg(inplace, 'inplace')
2655-
axis = self._get_axis_number(axis)
2655+
# Validate the axis parameter
2656+
self._get_axis_number(axis)
26562657
index = self.index
26572658

26582659
if level is not None:
@@ -3073,7 +3074,8 @@ def _gotitem(self, key, ndim, subset=None):
30733074
versionadded='.. versionadded:: 0.20.0',
30743075
**_shared_doc_kwargs))
30753076
def aggregate(self, func, axis=0, *args, **kwargs):
3076-
axis = self._get_axis_number(axis)
3077+
# Validate the axis parameter
3078+
self._get_axis_number(axis)
30773079
result, how = self._aggregate(func, *args, **kwargs)
30783080
if result is None:
30793081

@@ -3919,8 +3921,8 @@ def dropna(self, axis=0, inplace=False, **kwargs):
39193921
if kwargs:
39203922
raise TypeError('dropna() got an unexpected keyword '
39213923
'argument "{0}"'.format(list(kwargs.keys())[0]))
3922-
3923-
axis = self._get_axis_number(axis or 0)
3924+
# Validate the axis parameter
3925+
self._get_axis_number(axis or 0)
39243926

39253927
if self._can_hold_na:
39263928
result = remove_na_arraylike(self)

0 commit comments

Comments
 (0)