From 8c2e1caaf4a07c9623a5b3b4b4adbf2627853c08 Mon Sep 17 00:00:00 2001 From: phofl Date: Sun, 6 Dec 2020 21:49:18 +0100 Subject: [PATCH 01/14] BUG: read_csv not converting to float for python engine with decimal sep, usecols and parse_dates --- doc/source/whatsnew/v1.2.0.rst | 1 + pandas/io/parsers.py | 6 +++++- .../tests/io/parser/test_python_parser_only.py | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.2.0.rst b/doc/source/whatsnew/v1.2.0.rst index ac930b3e77785..6843c1f1076a6 100644 --- a/doc/source/whatsnew/v1.2.0.rst +++ b/doc/source/whatsnew/v1.2.0.rst @@ -724,6 +724,7 @@ I/O - Bug in :meth:`DataFrame.to_hdf` was not dropping missing rows with ``dropna=True`` (:issue:`35719`) - Bug in :func:`read_html` was raising a ``TypeError`` when supplying a ``pathlib.Path`` argument to the ``io`` parameter (:issue:`37705`) - :meth:`DataFrame.to_excel`, :meth:`Series.to_excel`, :meth:`DataFrame.to_markdown`, and :meth:`Series.to_markdown` now support writing to fsspec URLs such as S3 and Google Cloud Storage (:issue:`33987`) +- Bug in :meth:`read_csv` returning object dtype when ``delimiter=","`` with ``usecols`` and ``parse_dates`` specified for ``engine="python"`` (:issue:`35873`) - Bug in :func:`read_fwf` with ``skip_blank_lines=True`` was not skipping blank lines (:issue:`37758`) - Parse missing values using :func:`read_json` with ``dtype=False`` to ``NaN`` instead of ``None`` (:issue:`28501`) - :meth:`read_fwf` was inferring compression with ``compression=None`` which was not consistent with the other :meth:``read_*`` functions (:issue:`37909`) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 5b623c360c3ef..1f114cfe462e5 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -2354,12 +2354,16 @@ def _set_no_thousands_columns(self): # Create a set of column ids that are not to be stripped of thousands # operators. noconvert_columns = set() + if self._col_indices is not None: + col_indices = sorted(self._col_indices) + else: + col_indices = list(range(len(self.columns))) def _set(x): if is_integer(x): noconvert_columns.add(x) else: - noconvert_columns.add(self.columns.index(x)) + noconvert_columns.add(col_indices[self.columns.index(x)]) if isinstance(self.parse_dates, list): for val in self.parse_dates: diff --git a/pandas/tests/io/parser/test_python_parser_only.py b/pandas/tests/io/parser/test_python_parser_only.py index 4d933fa02d36f..ff606dd36c608 100644 --- a/pandas/tests/io/parser/test_python_parser_only.py +++ b/pandas/tests/io/parser/test_python_parser_only.py @@ -12,7 +12,7 @@ from pandas.errors import ParserError -from pandas import DataFrame, Index, MultiIndex +from pandas import DataFrame, Index, MultiIndex, Timestamp import pandas._testing as tm @@ -314,3 +314,19 @@ def test_malformed_skipfooter(python_parser_only): msg = "Expected 3 fields in line 4, saw 5" with pytest.raises(ParserError, match=msg): parser.read_csv(StringIO(data), header=1, comment="#", skipfooter=1) + + +def test_delimiter_with_usecols_and_parse_dates(python_parser_only): + # GH#35873 + result = python_parser_only.read_csv( + StringIO('"dump","-9,1","-9,1",20101010'), + engine="python", + names=["col", "col1", "col2", "col3"], + usecols=["col1", "col2", "col3"], + parse_dates=["col3"], + decimal=",", + ) + expected = DataFrame( + {"col1": [-9.1], "col2": [-9.1], "col3": [Timestamp("2010-10-10")]} + ) + tm.assert_frame_equal(result, expected) From c1b9a7b62a5881253b30a09aa72773dfb4cb495d Mon Sep 17 00:00:00 2001 From: phofl Date: Mon, 7 Dec 2020 21:14:40 +0100 Subject: [PATCH 02/14] Move sorted --- pandas/io/parsers.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 1f114cfe462e5..6acb594c9a6e6 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -2336,6 +2336,9 @@ def __init__(self, f: Union[FilePathOrBuffer, List], **kwds): if self.index_names is None: self.index_names = index_names + if self._col_indices is None: + self._col_indices = list(range(len(self.columns))) + self._validate_parse_dates_presence(self.columns) if self.parse_dates: self._no_thousands_columns = self._set_no_thousands_columns() @@ -2354,16 +2357,12 @@ def _set_no_thousands_columns(self): # Create a set of column ids that are not to be stripped of thousands # operators. noconvert_columns = set() - if self._col_indices is not None: - col_indices = sorted(self._col_indices) - else: - col_indices = list(range(len(self.columns))) def _set(x): if is_integer(x): noconvert_columns.add(x) else: - noconvert_columns.add(col_indices[self.columns.index(x)]) + noconvert_columns.add(self._col_indices[self.columns.index(x)]) if isinstance(self.parse_dates, list): for val in self.parse_dates: @@ -2795,7 +2794,7 @@ def _handle_usecols(self, columns, usecols_key): [n for i, n in enumerate(column) if i in col_indices] for column in columns ] - self._col_indices = col_indices + self._col_indices = sorted(col_indices) return columns def _buffered_line(self): From 76b91bfdd9e25762a7c613951d02b77f52db07a2 Mon Sep 17 00:00:00 2001 From: phofl Date: Tue, 8 Dec 2020 23:28:34 +0100 Subject: [PATCH 03/14] Fix mypy issues --- pandas/io/parsers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 6acb594c9a6e6..69bb90cdf4458 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -2294,7 +2294,6 @@ def __init__(self, f: Union[FilePathOrBuffer, List], **kwds): # Get columns in two steps: infer from data, then # infer column indices from self.usecols if it is specified. - self._col_indices = None try: ( self.columns, @@ -2336,7 +2335,7 @@ def __init__(self, f: Union[FilePathOrBuffer, List], **kwds): if self.index_names is None: self.index_names = index_names - if self._col_indices is None: + if not hasattr(self, "_col_indices"): self._col_indices = list(range(len(self.columns))) self._validate_parse_dates_presence(self.columns) @@ -2712,7 +2711,6 @@ def _infer_columns(self): # overwritten. self._handle_usecols(columns, names) else: - self._col_indices = None num_original_columns = len(names) columns = [names] else: @@ -3196,7 +3194,7 @@ def _rows_to_cols(self, content): i < len(self.index_col) # pandas\io\parsers.py:3159: error: Unsupported right # operand type for in ("Optional[Any]") [operator] - or i - len(self.index_col) # type: ignore[operator] + or i - len(self.index_col) in self._col_indices ) ] @@ -3206,7 +3204,7 @@ def _rows_to_cols(self, content): # operand type for in ("Optional[Any]") [operator] a for i, a in enumerate(zipped_content) - if i in self._col_indices # type: ignore[operator] + if i in self._col_indices ] return zipped_content From 9de505934b4e3184f988de40470cb58c9b17d7e0 Mon Sep 17 00:00:00 2001 From: phofl Date: Tue, 8 Dec 2020 23:29:36 +0100 Subject: [PATCH 04/14] Run black --- pandas/io/parsers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 69bb90cdf4458..646bea363a4e1 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -3194,8 +3194,7 @@ def _rows_to_cols(self, content): i < len(self.index_col) # pandas\io\parsers.py:3159: error: Unsupported right # operand type for in ("Optional[Any]") [operator] - or i - len(self.index_col) - in self._col_indices + or i - len(self.index_col) in self._col_indices ) ] else: From 85a3d22b3f9e97e3c4c040bc0f8b6dd39fc43812 Mon Sep 17 00:00:00 2001 From: phofl Date: Tue, 8 Dec 2020 23:31:47 +0100 Subject: [PATCH 05/14] Move whatsnew --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 90f611c55e710..105e9618ce11a 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -146,7 +146,7 @@ MultiIndex I/O ^^^ -- +- Bug in :meth:`read_csv` returning object dtype when ``delimiter=","`` with ``usecols`` and ``parse_dates`` specified for ``engine="python"`` (:issue:`35873`) - Period From 2958d2a92bec37df35d7a25f195a557f9c1914a9 Mon Sep 17 00:00:00 2001 From: phofl Date: Wed, 9 Dec 2020 19:51:46 +0100 Subject: [PATCH 06/14] Remove comment --- pandas/io/parsers.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 646bea363a4e1..8c5dab1940863 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -3192,18 +3192,12 @@ def _rows_to_cols(self, content): for i, a in enumerate(zipped_content) if ( i < len(self.index_col) - # pandas\io\parsers.py:3159: error: Unsupported right - # operand type for in ("Optional[Any]") [operator] or i - len(self.index_col) in self._col_indices ) ] else: zipped_content = [ - # pandas\io\parsers.py:3164: error: Unsupported right - # operand type for in ("Optional[Any]") [operator] - a - for i, a in enumerate(zipped_content) - if i in self._col_indices + a for i, a in enumerate(zipped_content) if i in self._col_indices ] return zipped_content From 88bf3950228b2e62713b523a80f9fa416645c4f7 Mon Sep 17 00:00:00 2001 From: phofl Date: Fri, 11 Dec 2020 18:32:12 +0100 Subject: [PATCH 07/14] Remove from 1.2 --- doc/source/whatsnew/v1.2.0.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v1.2.0.rst b/doc/source/whatsnew/v1.2.0.rst index 61804b09edc1d..af9219bc25931 100644 --- a/doc/source/whatsnew/v1.2.0.rst +++ b/doc/source/whatsnew/v1.2.0.rst @@ -740,7 +740,6 @@ I/O - Bug in :meth:`DataFrame.to_hdf` was not dropping missing rows with ``dropna=True`` (:issue:`35719`) - Bug in :func:`read_html` was raising a ``TypeError`` when supplying a ``pathlib.Path`` argument to the ``io`` parameter (:issue:`37705`) - :meth:`DataFrame.to_excel`, :meth:`Series.to_excel`, :meth:`DataFrame.to_markdown`, and :meth:`Series.to_markdown` now support writing to fsspec URLs such as S3 and Google Cloud Storage (:issue:`33987`) -- Bug in :meth:`read_csv` returning object dtype when ``delimiter=","`` with ``usecols`` and ``parse_dates`` specified for ``engine="python"`` (:issue:`35873`) - Bug in :func:`read_fwf` with ``skip_blank_lines=True`` was not skipping blank lines (:issue:`37758`) - Parse missing values using :func:`read_json` with ``dtype=False`` to ``NaN`` instead of ``None`` (:issue:`28501`) - :meth:`read_fwf` was inferring compression with ``compression=None`` which was not consistent with the other :meth:``read_*`` functions (:issue:`37909`) From 384c114fd6935001cfa43b4eee0f1870a8b32b03 Mon Sep 17 00:00:00 2001 From: phofl Date: Tue, 15 Dec 2020 21:32:27 +0100 Subject: [PATCH 08/14] Move test --- pandas/tests/io/parser/test_dtypes.py | 16 ++++++++++++++++ .../tests/io/parser/test_python_parser_only.py | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pandas/tests/io/parser/test_dtypes.py b/pandas/tests/io/parser/test_dtypes.py index 1e68e54b413b0..c3ce5be2a3a64 100644 --- a/pandas/tests/io/parser/test_dtypes.py +++ b/pandas/tests/io/parser/test_dtypes.py @@ -603,3 +603,19 @@ def test_boolean_dtype(all_parsers): ) tm.assert_frame_equal(result, expected) + + +def test_delimiter_with_usecols_and_parse_dates(all_parsers): + # GH#35873 + result = all_parsers.read_csv( + StringIO('"dump","-9,1","-9,1",20101010'), + engine="python", + names=["col", "col1", "col2", "col3"], + usecols=["col1", "col2", "col3"], + parse_dates=["col3"], + decimal=",", + ) + expected = DataFrame( + {"col1": [-9.1], "col2": [-9.1], "col3": [Timestamp("2010-10-10")]} + ) + tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/io/parser/test_python_parser_only.py b/pandas/tests/io/parser/test_python_parser_only.py index c9fa33c113e57..067ad28b727d8 100644 --- a/pandas/tests/io/parser/test_python_parser_only.py +++ b/pandas/tests/io/parser/test_python_parser_only.py @@ -314,19 +314,3 @@ def test_malformed_skipfooter(python_parser_only): msg = "Expected 3 fields in line 4, saw 5" with pytest.raises(ParserError, match=msg): parser.read_csv(StringIO(data), header=1, comment="#", skipfooter=1) - - -def test_delimiter_with_usecols_and_parse_dates(python_parser_only): - # GH#35873 - result = python_parser_only.read_csv( - StringIO('"dump","-9,1","-9,1",20101010'), - engine="python", - names=["col", "col1", "col2", "col3"], - usecols=["col1", "col2", "col3"], - parse_dates=["col3"], - decimal=",", - ) - expected = DataFrame( - {"col1": [-9.1], "col2": [-9.1], "col3": [Timestamp("2010-10-10")]} - ) - tm.assert_frame_equal(result, expected) From 70780da9d5121cb05e4f76cb6bf942c6e4212812 Mon Sep 17 00:00:00 2001 From: phofl Date: Tue, 15 Dec 2020 22:14:07 +0100 Subject: [PATCH 09/14] Remove import --- pandas/tests/io/parser/test_python_parser_only.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/parser/test_python_parser_only.py b/pandas/tests/io/parser/test_python_parser_only.py index 067ad28b727d8..016fae4f4a6f5 100644 --- a/pandas/tests/io/parser/test_python_parser_only.py +++ b/pandas/tests/io/parser/test_python_parser_only.py @@ -12,7 +12,7 @@ from pandas.errors import ParserError -from pandas import DataFrame, Index, MultiIndex, Timestamp +from pandas import DataFrame, Index, MultiIndex import pandas._testing as tm From 4afa2c8dba26a21b3949b2e576ad6cad2338c612 Mon Sep 17 00:00:00 2001 From: phofl Date: Sat, 2 Jan 2021 00:13:12 +0100 Subject: [PATCH 10/14] Always define self._col_indices --- pandas/io/parsers.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index f089d5af4463d..cda73e6ed11f6 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -2293,6 +2293,7 @@ def __init__(self, f: Union[FilePathOrBuffer, List], **kwds): # Get columns in two steps: infer from data, then # infer column indices from self.usecols if it is specified. + self._col_indices: Optional[List[int]] = None try: ( self.columns, @@ -2334,7 +2335,7 @@ def __init__(self, f: Union[FilePathOrBuffer, List], **kwds): if self.index_names is None: self.index_names = index_names - if not hasattr(self, "_col_indices"): + if self._col_indices is None: self._col_indices = list(range(len(self.columns))) self._validate_parse_dates_presence(self.columns) @@ -2360,7 +2361,11 @@ def _set(x): if is_integer(x): noconvert_columns.add(x) else: - noconvert_columns.add(self._col_indices[self.columns.index(x)]) + # pandas\io\parsers.py:2366: error: Unsupported right + # operand type for in ("Optional[List[int]") [index] + noconvert_columns.add( + self._col_indices[self.columns.index(x)] # type: ignore[index] + ) if isinstance(self.parse_dates, list): for val in self.parse_dates: @@ -3185,14 +3190,21 @@ def _rows_to_cols(self, content): zipped_content = [ a for i, a in enumerate(zipped_content) + # pandas\io\parsers.py:2366: error: Unsupported right + # operand type for in ("Optional[List[int]") [operator] if ( i < len(self.index_col) - or i - len(self.index_col) in self._col_indices + or i - len(self.index_col) # type: ignore[operator] + in self._col_indices ) ] else: + # pandas\io\parsers.py:3202: error: Unsupported right + # operand type for in ("Optional[List[int]") [operator] zipped_content = [ - a for i, a in enumerate(zipped_content) if i in self._col_indices + a + for i, a in enumerate(zipped_content) + if i in self._col_indices # type: ignore[operator] ] return zipped_content From 5bee24a94e46c4bfaf742e4f3de5302dca7a973c Mon Sep 17 00:00:00 2001 From: phofl Date: Sat, 2 Jan 2021 00:14:41 +0100 Subject: [PATCH 11/14] Move comments --- pandas/io/parsers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index cda73e6ed11f6..e690304e16963 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -3190,18 +3190,18 @@ def _rows_to_cols(self, content): zipped_content = [ a for i, a in enumerate(zipped_content) - # pandas\io\parsers.py:2366: error: Unsupported right - # operand type for in ("Optional[List[int]") [operator] if ( i < len(self.index_col) + # pandas\io\parsers.py:2366: error: Unsupported right + # operand type for in ("Optional[List[int]") [operator] or i - len(self.index_col) # type: ignore[operator] in self._col_indices ) ] else: - # pandas\io\parsers.py:3202: error: Unsupported right - # operand type for in ("Optional[List[int]") [operator] zipped_content = [ + # pandas\io\parsers.py:3202: error: Unsupported right + # operand type for in ("Optional[List[int]") [operator] a for i, a in enumerate(zipped_content) if i in self._col_indices # type: ignore[operator] From c6a226b1e4056957d1cffbd1428a5cb4a2787e29 Mon Sep 17 00:00:00 2001 From: phofl Date: Sat, 2 Jan 2021 00:16:21 +0100 Subject: [PATCH 12/14] Add init files --- .../{test_dtypes.py => dtypes/__init__.py} | 0 .../io/parser/dtypes/test_dtypes_basic.py | 18 +++++++++++++++++- pandas/tests/io/parser/usecols/__init__.py | 0 3 files changed, 17 insertions(+), 1 deletion(-) rename pandas/tests/io/parser/{test_dtypes.py => dtypes/__init__.py} (100%) create mode 100644 pandas/tests/io/parser/usecols/__init__.py diff --git a/pandas/tests/io/parser/test_dtypes.py b/pandas/tests/io/parser/dtypes/__init__.py similarity index 100% rename from pandas/tests/io/parser/test_dtypes.py rename to pandas/tests/io/parser/dtypes/__init__.py diff --git a/pandas/tests/io/parser/dtypes/test_dtypes_basic.py b/pandas/tests/io/parser/dtypes/test_dtypes_basic.py index e416d8dcdd905..fc34d65fdad52 100644 --- a/pandas/tests/io/parser/dtypes/test_dtypes_basic.py +++ b/pandas/tests/io/parser/dtypes/test_dtypes_basic.py @@ -10,7 +10,7 @@ from pandas.errors import ParserWarning import pandas as pd -from pandas import DataFrame +from pandas import DataFrame, Timestamp import pandas._testing as tm @@ -165,3 +165,19 @@ def test_boolean_dtype(all_parsers): ) tm.assert_frame_equal(result, expected) + + +def test_delimiter_with_usecols_and_parse_dates(all_parsers): + # GH#35873 + result = all_parsers.read_csv( + StringIO('"dump","-9,1","-9,1",20101010'), + engine="python", + names=["col", "col1", "col2", "col3"], + usecols=["col1", "col2", "col3"], + parse_dates=["col3"], + decimal=",", + ) + expected = DataFrame( + {"col1": [-9.1], "col2": [-9.1], "col3": [Timestamp("2010-10-10")]} + ) + tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/io/parser/usecols/__init__.py b/pandas/tests/io/parser/usecols/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d From 3ece01b849b94b14e65a6770d493b51c3ebf2fe5 Mon Sep 17 00:00:00 2001 From: phofl Date: Sat, 2 Jan 2021 00:17:11 +0100 Subject: [PATCH 13/14] Fix line numbers --- pandas/io/parsers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index fbb4c8a0b0fcb..a49c616baa561 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -3192,7 +3192,7 @@ def _rows_to_cols(self, content): for i, a in enumerate(zipped_content) if ( i < len(self.index_col) - # pandas\io\parsers.py:2366: error: Unsupported right + # pandas\io\parsers.py:3198: error: Unsupported right # operand type for in ("Optional[List[int]") [operator] or i - len(self.index_col) # type: ignore[operator] in self._col_indices @@ -3200,7 +3200,7 @@ def _rows_to_cols(self, content): ] else: zipped_content = [ - # pandas\io\parsers.py:3202: error: Unsupported right + # pandas\io\parsers.py:3207: error: Unsupported right # operand type for in ("Optional[List[int]") [operator] a for i, a in enumerate(zipped_content) From 6cca96057636b348d06580c754de880a820f9a49 Mon Sep 17 00:00:00 2001 From: phofl Date: Sun, 3 Jan 2021 19:39:33 +0100 Subject: [PATCH 14/14] Remove mypy ignores --- pandas/io/parsers.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index a49c616baa561..670da07869b72 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -2361,11 +2361,9 @@ def _set(x): if is_integer(x): noconvert_columns.add(x) else: - # pandas\io\parsers.py:2366: error: Unsupported right - # operand type for in ("Optional[List[int]") [index] - noconvert_columns.add( - self._col_indices[self.columns.index(x)] # type: ignore[index] - ) + assert self._col_indices is not None + col_indices = self._col_indices + noconvert_columns.add(col_indices[self.columns.index(x)]) if isinstance(self.parse_dates, list): for val in self.parse_dates: @@ -3186,25 +3184,21 @@ def _rows_to_cols(self, content): zipped_content = list(lib.to_object_array(content, min_width=col_len).T) if self.usecols: + assert self._col_indices is not None + col_indices = self._col_indices + if self._implicit_index: zipped_content = [ a for i, a in enumerate(zipped_content) if ( i < len(self.index_col) - # pandas\io\parsers.py:3198: error: Unsupported right - # operand type for in ("Optional[List[int]") [operator] - or i - len(self.index_col) # type: ignore[operator] - in self._col_indices + or i - len(self.index_col) in col_indices ) ] else: zipped_content = [ - # pandas\io\parsers.py:3207: error: Unsupported right - # operand type for in ("Optional[List[int]") [operator] - a - for i, a in enumerate(zipped_content) - if i in self._col_indices # type: ignore[operator] + a for i, a in enumerate(zipped_content) if i in col_indices ] return zipped_content