diff --git a/pandas/_libs/parsers.pyx b/pandas/_libs/parsers.pyx index 89d2de6de213a..52ca3d1226f79 100644 --- a/pandas/_libs/parsers.pyx +++ b/pandas/_libs/parsers.pyx @@ -1045,7 +1045,7 @@ cdef class TextReader: usecols = set() if callable(self.usecols): if self.usecols(name): - usecols = set([i]) + usecols = {i} else: usecols = self.usecols if self.has_usecols and not (i in usecols or diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index 09aeff852a0f2..2ecd55ea88170 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -57,7 +57,7 @@ _DEFAULT_DATETIME = datetime(1, 1, 1).replace(hour=0, minute=0, cdef object _TIMEPAT = re.compile(r'^([01]?[0-9]|2[0-3]):([0-5][0-9])') -cdef set _not_datelike_strings = set(['a', 'A', 'm', 'M', 'p', 'P', 't', 'T']) +cdef set _not_datelike_strings = {'a', 'A', 'm', 'M', 'p', 'P', 't', 'T'} NAT_SENTINEL = object() # This allows us to reference NaT without having to import it @@ -651,7 +651,7 @@ def _guess_datetime_format(dt_str, dayfirst=False, dt_str_parse=du_parse, break # Only consider it a valid guess if we have a year, month and day - if len(set(['year', 'month', 'day']) & found_attrs) != 3: + if len({'year', 'month', 'day'} & found_attrs) != 3: return None output_format = [] diff --git a/pandas/compat/pickle_compat.py b/pandas/compat/pickle_compat.py index e444c4002c2c0..c1a9a9fc1ed13 100644 --- a/pandas/compat/pickle_compat.py +++ b/pandas/compat/pickle_compat.py @@ -38,9 +38,9 @@ def load_reduce(self): # try to re-encode the arguments if getattr(self, 'encoding', None) is not None: - args = tuple([arg.encode(self.encoding) - if isinstance(arg, string_types) - else arg for arg in args]) + args = tuple(arg.encode(self.encoding) + if isinstance(arg, string_types) + else arg for arg in args) try: stack[-1] = func(*args) return diff --git a/pandas/core/generic.py b/pandas/core/generic.py index c411e29b5cc02..a45887543dc53 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -212,9 +212,8 @@ def _dir_additions(self): """ add the string-like attributes from the info_axis. If info_axis is a MultiIndex, it's first level values are used. """ - additions = set( - [c for c in self._info_axis.unique(level=0)[:100] - if isinstance(c, string_types) and isidentifier(c)]) + additions = {c for c in self._info_axis.unique(level=0)[:100] + if isinstance(c, string_types) and isidentifier(c)} return super(NDFrame, self)._dir_additions().union(additions) @property diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 2aa490cd02afb..ec2874b3bae95 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -905,9 +905,8 @@ def _multi_take(self, tup): """ try: o = self.obj - d = dict( - [(a, self._convert_for_reindex(t, axis=o._get_axis_number(a))) - for t, a in zip(tup, o._AXIS_ORDERS)]) + d = {a: self._convert_for_reindex(t, axis=o._get_axis_number(a)) + for t, a in zip(tup, o._AXIS_ORDERS)} return o.reindex(**d) except(KeyError, IndexingError): raise self._exception