diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 928483005786a..60464bcfda1e7 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -814,7 +814,6 @@ def _format_data(self): summary = '[{head} ... {tail}]'.format( head=', '.join(head), tail=', '.join(tail)) else: - head = [] tail = [formatter(x) for x in self] summary = '[{tail}]'.format(tail=', '.join(tail)) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 57b1d81d94754..cf771a127a696 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -305,7 +305,6 @@ def _hash_categories(categories, ordered=True): # everything to a str first, which means we treat # {'1', '2'} the same as {'1', 2} # find a better solution - cat_array = np.array([hash(x) for x in categories]) hashed = hash((tuple(categories), ordered)) return hashed cat_array = hash_array(np.asarray(categories), categorize=False) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 4c87f6122b956..5b2590cfcf010 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -134,7 +134,6 @@ def _cython_agg_blocks(self, how, alt=None, numeric_only=True, obj = self.obj[data.items[locs]] s = groupby(obj, self.grouper) result = s.aggregate(lambda x: alt(x, axis=self.axis)) - newb = result._data.blocks[0] finally: diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 8ad058c001bba..2a191ef76473b 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1647,11 +1647,11 @@ def is_int(v): # if we are mixed and have integers try: if is_positional and self.is_mixed(): - # TODO: i, j are not used anywhere + # Validate start & stop if start is not None: - i = self.get_loc(start) # noqa + self.get_loc(start) if stop is not None: - j = self.get_loc(stop) # noqa + self.get_loc(stop) is_positional = False except KeyError: if self.inferred_type == 'mixed-integer-float': diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 13c019dea469a..80b3d579d5447 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -788,11 +788,6 @@ def _align_frame(self, indexer, df): if isinstance(indexer, tuple): - aligners = [not com.is_null_slice(idx) for idx in indexer] - sum_aligners = sum(aligners) - # TODO: single_aligner is not used - single_aligner = sum_aligners == 1 # noqa - idx, cols = None, None sindexers = [] for i, ix in enumerate(indexer): @@ -865,9 +860,6 @@ def _align_frame(self, indexer, df): raise ValueError('Incompatible indexer with DataFrame') def _align_panel(self, indexer, df): - # TODO: is_frame, is_panel are unused - is_frame = self.obj.ndim == 2 # noqa - is_panel = self.obj.ndim >= 3 # noqa raise NotImplementedError("cannot set using an indexer with a Panel " "yet!") diff --git a/pandas/core/ops.py b/pandas/core/ops.py index c65d2dcdc478c..6d407c41daea6 100644 --- a/pandas/core/ops.py +++ b/pandas/core/ops.py @@ -1789,7 +1789,7 @@ def na_op(x, y): def f(self, other, axis=None): # Validate the axis parameter if axis is not None: - axis = self._get_axis_number(axis) + self._get_axis_number(axis) if isinstance(other, self._constructor): return self._compare_constructor(other, na_op, try_cast=False) diff --git a/pandas/core/panel.py b/pandas/core/panel.py index 38b84ab685c3b..fd27e3ba650ea 100644 --- a/pandas/core/panel.py +++ b/pandas/core/panel.py @@ -296,7 +296,7 @@ def _getitem_multilevel(self, key): if isinstance(loc, (slice, np.ndarray)): new_index = info[loc] result_index = maybe_droplevels(new_index, key) - slices = [loc] + [slice(None) for x in range(self._AXIS_LEN - 1)] + slices = [loc] + [slice(None)] * (self._AXIS_LEN - 1) new_values = self.values[slices] d = self._construct_axes_dict(self._AXIS_ORDERS[1:]) diff --git a/pandas/core/sparse/series.py b/pandas/core/sparse/series.py index 1a92a27bfb390..8ac5d81f23bb2 100644 --- a/pandas/core/sparse/series.py +++ b/pandas/core/sparse/series.py @@ -624,8 +624,9 @@ def cumsum(self, axis=0, *args, **kwargs): cumsum : SparseSeries """ nv.validate_cumsum(args, kwargs) + # Validate axis if axis is not None: - axis = self._get_axis_number(axis) + self._get_axis_number(axis) new_array = self.values.cumsum() @@ -654,7 +655,8 @@ def dropna(self, axis=0, inplace=False, **kwargs): Analogous to Series.dropna. If fill_value=NaN, returns a dense Series """ # TODO: make more efficient - axis = self._get_axis_number(axis or 0) + # Validate axis + self._get_axis_number(axis or 0) dense_valid = self.to_dense().dropna() if inplace: raise NotImplementedError("Cannot perform inplace dropna" diff --git a/pandas/io/excel.py b/pandas/io/excel.py index 39131d390c69f..e2db6643c5ef0 100644 --- a/pandas/io/excel.py +++ b/pandas/io/excel.py @@ -647,7 +647,7 @@ def _parse_cell(cell_contents, cell_typ): if header is not None: if is_list_like(header): header_names = [] - control_row = [True for x in data[0]] + control_row = [True] * len(data[0]) for row in header: if is_integer(skiprows): row += skiprows diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py index c6ca59aa08bf9..1ff0613876838 100644 --- a/pandas/io/formats/format.py +++ b/pandas/io/formats/format.py @@ -1567,7 +1567,7 @@ def get_level_lengths(levels, sentinel=''): if len(levels) == 0: return [] - control = [True for x in levels[0]] + control = [True] * len(levels[0]) result = [] for level in levels: diff --git a/pandas/io/formats/html.py b/pandas/io/formats/html.py index 3ea5cb95b9c5a..a6b03c9c6dd23 100644 --- a/pandas/io/formats/html.py +++ b/pandas/io/formats/html.py @@ -369,7 +369,7 @@ def _write_regular_rows(self, fmt_values, indent): for i in range(nrows): if truncate_v and i == (self.fmt.tr_row_num): - str_sep_row = ['...' for ele in row] + str_sep_row = ['...'] * len(row) self.write_tr(str_sep_row, indent, self.indent_delta, tags=None, nindex_levels=1)