The following issues were found
pandas/tests/tseries/frequencies/test_frequencies.py
8 issues
Line: 1
Column: 1
import pytest
from pandas._libs.tslibs import offsets
from pandas.tseries.frequencies import (
is_subperiod,
is_superperiod,
)
Reported by Pylint.
Line: 3
Column: 1
import pytest
from pandas._libs.tslibs import offsets
from pandas.tseries.frequencies import (
is_subperiod,
is_superperiod,
)
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas._libs.tslibs import offsets
from pandas.tseries.frequencies import (
is_subperiod,
is_superperiod,
)
Reported by Pylint.
Line: 25
Column: 1
(offsets.Second(), offsets.Milli(), True),
(offsets.Milli(), offsets.Micro(), True),
(offsets.Micro(), offsets.Nano(), True),
],
)
def test_super_sub_symmetry(p1, p2, expected):
assert is_superperiod(p1, p2) is expected
assert is_subperiod(p2, p1) is expected
Reported by Pylint.
Line: 25
Column: 1
(offsets.Second(), offsets.Milli(), True),
(offsets.Milli(), offsets.Micro(), True),
(offsets.Micro(), offsets.Nano(), True),
],
)
def test_super_sub_symmetry(p1, p2, expected):
assert is_superperiod(p1, p2) is expected
assert is_subperiod(p2, p1) is expected
Reported by Pylint.
Line: 25
Column: 1
(offsets.Second(), offsets.Milli(), True),
(offsets.Milli(), offsets.Micro(), True),
(offsets.Micro(), offsets.Nano(), True),
],
)
def test_super_sub_symmetry(p1, p2, expected):
assert is_superperiod(p1, p2) is expected
assert is_subperiod(p2, p1) is expected
Reported by Pylint.
Line: 28
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
],
)
def test_super_sub_symmetry(p1, p2, expected):
assert is_superperiod(p1, p2) is expected
assert is_subperiod(p2, p1) is expected
Reported by Bandit.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_super_sub_symmetry(p1, p2, expected):
assert is_superperiod(p1, p2) is expected
assert is_subperiod(p2, p1) is expected
Reported by Bandit.
pandas/tests/window/test_dtypes.py
8 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
from pandas.core.base import DataError
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
from pandas.core.base import DataError
Reported by Pylint.
Line: 18
Column: 1
# compliance (though both expanding and ewm inherit)
def get_dtype(dtype, coerce_int=None):
if coerce_int is False and "int" in dtype:
return None
if dtype != "category":
return np.dtype(dtype)
return dtype
Reported by Pylint.
Line: 64
Column: 1
[np.nan, 0.5, 1.5, np.nan, np.nan],
False,
None,
),
],
)
def test_series_dtypes(method, data, expected_data, coerce_int, dtypes, min_periods):
s = Series(data, dtype=get_dtype(dtypes, coerce_int=coerce_int))
if dtypes in ("m8[ns]", "M8[ns]") and method != "count":
Reported by Pylint.
Line: 64
Column: 1
[np.nan, 0.5, 1.5, np.nan, np.nan],
False,
None,
),
],
)
def test_series_dtypes(method, data, expected_data, coerce_int, dtypes, min_periods):
s = Series(data, dtype=get_dtype(dtypes, coerce_int=coerce_int))
if dtypes in ("m8[ns]", "M8[ns]") and method != "count":
Reported by Pylint.
Line: 68
Column: 5
],
)
def test_series_dtypes(method, data, expected_data, coerce_int, dtypes, min_periods):
s = Series(data, dtype=get_dtype(dtypes, coerce_int=coerce_int))
if dtypes in ("m8[ns]", "M8[ns]") and method != "count":
msg = "No numeric types to aggregate"
with pytest.raises(DataError, match=msg):
getattr(s.rolling(2, min_periods=min_periods), method)()
else:
Reported by Pylint.
Line: 120
Column: 1
"median",
{0: Series([np.nan, 1, 3, 5, 7]), 1: Series([np.nan, 2, 4, 6, 8])},
None,
),
],
)
def test_dataframe_dtypes(method, expected_data, dtypes, min_periods):
if dtypes == "category":
pytest.skip("Category dataframe testing not implemented.")
Reported by Pylint.
Line: 126
Column: 5
def test_dataframe_dtypes(method, expected_data, dtypes, min_periods):
if dtypes == "category":
pytest.skip("Category dataframe testing not implemented.")
df = DataFrame(np.arange(10).reshape((5, 2)), dtype=get_dtype(dtypes))
if dtypes in ("m8[ns]", "M8[ns]") and method != "count":
msg = "No numeric types to aggregate"
with pytest.raises(DataError, match=msg):
getattr(df.rolling(2, min_periods=min_periods), method)()
else:
Reported by Pylint.
pandas/tests/util/test_validate_args.py
8 issues
Line: 1
Column: 1
import pytest
from pandas.util._validators import validate_args
_fname = "func"
def test_bad_min_fname_arg_count():
msg = "'max_fname_arg_count' must be non-negative"
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas.util._validators import validate_args
_fname = "func"
def test_bad_min_fname_arg_count():
msg = "'max_fname_arg_count' must be non-negative"
Reported by Pylint.
Line: 5
Column: 1
from pandas.util._validators import validate_args
_fname = "func"
def test_bad_min_fname_arg_count():
msg = "'max_fname_arg_count' must be non-negative"
Reported by Pylint.
Line: 8
Column: 1
_fname = "func"
def test_bad_min_fname_arg_count():
msg = "'max_fname_arg_count' must be non-negative"
with pytest.raises(ValueError, match=msg):
validate_args(_fname, (None,), -1, "foo")
Reported by Pylint.
Line: 15
Column: 1
validate_args(_fname, (None,), -1, "foo")
def test_bad_arg_length_max_value_single():
args = (None, None)
compat_args = ("foo",)
min_fname_arg_count = 0
max_length = len(compat_args) + min_fname_arg_count
Reported by Pylint.
Line: 31
Column: 1
validate_args(_fname, args, min_fname_arg_count, compat_args)
def test_bad_arg_length_max_value_multiple():
args = (None, None)
compat_args = {"foo": None}
min_fname_arg_count = 2
max_length = len(compat_args) + min_fname_arg_count
Reported by Pylint.
Line: 48
Column: 1
@pytest.mark.parametrize("i", range(1, 3))
def test_not_all_defaults(i):
bad_arg = "foo"
msg = (
f"the '{bad_arg}' parameter is not supported "
fr"in the pandas implementation of {_fname}\(\)"
)
Reported by Pylint.
Line: 62
Column: 1
validate_args(_fname, arg_vals[:i], 2, compat_args)
def test_validation():
# No exceptions should be raised.
validate_args(_fname, (None,), 2, {"out": None})
compat_args = {"axis": 1, "out": None}
validate_args(_fname, (1, None), 2, compat_args)
Reported by Pylint.
pandas/tests/util/test_validate_args_and_kwargs.py
8 issues
Line: 1
Column: 1
import pytest
from pandas.util._validators import validate_args_and_kwargs
_fname = "func"
def test_invalid_total_length_max_length_one():
compat_args = ("foo",)
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas.util._validators import validate_args_and_kwargs
_fname = "func"
def test_invalid_total_length_max_length_one():
compat_args = ("foo",)
Reported by Pylint.
Line: 5
Column: 1
from pandas.util._validators import validate_args_and_kwargs
_fname = "func"
def test_invalid_total_length_max_length_one():
compat_args = ("foo",)
kwargs = {"foo": "FOO"}
Reported by Pylint.
Line: 8
Column: 1
_fname = "func"
def test_invalid_total_length_max_length_one():
compat_args = ("foo",)
kwargs = {"foo": "FOO"}
args = ("FoO", "BaZ")
min_fname_arg_count = 0
Reported by Pylint.
Line: 26
Column: 1
validate_args_and_kwargs(_fname, args, kwargs, min_fname_arg_count, compat_args)
def test_invalid_total_length_max_length_multiple():
compat_args = ("foo", "bar", "baz")
kwargs = {"foo": "FOO", "bar": "BAR"}
args = ("FoO", "BaZ")
min_fname_arg_count = 2
Reported by Pylint.
Line: 45
Column: 1
@pytest.mark.parametrize("args,kwargs", [((), {"foo": -5, "bar": 2}), ((-5, 2), {})])
def test_missing_args_or_kwargs(args, kwargs):
bad_arg = "bar"
min_fname_arg_count = 2
compat_args = {"foo": -5, bad_arg: 1}
Reported by Pylint.
Line: 60
Column: 1
validate_args_and_kwargs(_fname, args, kwargs, min_fname_arg_count, compat_args)
def test_duplicate_argument():
min_fname_arg_count = 2
compat_args = {"foo": None, "bar": None, "baz": None}
kwargs = {"foo": None, "bar": None}
args = (None,) # duplicate value for "foo"
Reported by Pylint.
Line: 73
Column: 1
validate_args_and_kwargs(_fname, args, kwargs, min_fname_arg_count, compat_args)
def test_validation():
# No exceptions should be raised.
compat_args = {"foo": 1, "bar": None, "baz": -2}
kwargs = {"baz": -2}
args = (1, None)
Reported by Pylint.
pandas/core/ops/mask_ops.py
8 issues
Line: 8
Column: 1
import numpy as np
from pandas._libs import (
lib,
missing as libmissing,
)
Reported by Pylint.
Line: 8
Column: 1
import numpy as np
from pandas._libs import (
lib,
missing as libmissing,
)
Reported by Pylint.
Line: 43
Column: 16
# always come from an array, not a scalar. This is safe, since because
# A | B == B | A
if left_mask is None:
return kleene_or(right, left, right_mask, left_mask)
assert isinstance(left, np.ndarray)
raise_for_nan(right, method="or")
Reported by Pylint.
Line: 103
Column: 16
The result of the logical xor, and the new mask.
"""
if left_mask is None:
return kleene_xor(right, left, right_mask, left_mask)
raise_for_nan(right, method="xor")
if right is libmissing.NA:
result = np.zeros_like(left)
else:
Reported by Pylint.
Line: 152
Column: 16
# always come from an array, not a scalar. This is safe, since because
# A | B == B | A
if left_mask is None:
return kleene_and(right, left, right_mask, left_mask)
assert isinstance(left, np.ndarray)
raise_for_nan(right, method="and")
if right is libmissing.NA:
Reported by Pylint.
Line: 45
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if left_mask is None:
return kleene_or(right, left, right_mask, left_mask)
assert isinstance(left, np.ndarray)
raise_for_nan(right, method="or")
if right is libmissing.NA:
result = left.copy()
Reported by Bandit.
Line: 154
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if left_mask is None:
return kleene_and(right, left, right_mask, left_mask)
assert isinstance(left, np.ndarray)
raise_for_nan(right, method="and")
if right is libmissing.NA:
result = np.zeros_like(left)
else:
Reported by Bandit.
Line: 181
Column: 1
return result, mask
def raise_for_nan(value, method: str):
if lib.is_float(value) and np.isnan(value):
raise ValueError(f"Cannot perform logical '{method}' with floating NaN")
Reported by Pylint.
pandas/tests/indexes/datetimes/test_reindex.py
8 issues
Line: 1
Column: 1
from datetime import timedelta
import numpy as np
from pandas import (
DatetimeIndex,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 1
import pandas._testing as tm
class TestDatetimeIndexReindex:
def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self):
# GH#7774
index = date_range("2013-01-01", periods=3, tz="US/Eastern")
assert str(index.reindex([])[0].tz) == "US/Eastern"
assert str(index.reindex(np.array([]))[0].tz) == "US/Eastern"
Reported by Pylint.
Line: 13
Column: 5
class TestDatetimeIndexReindex:
def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self):
# GH#7774
index = date_range("2013-01-01", periods=3, tz="US/Eastern")
assert str(index.reindex([])[0].tz) == "US/Eastern"
assert str(index.reindex(np.array([]))[0].tz) == "US/Eastern"
Reported by Pylint.
Line: 13
Column: 5
class TestDatetimeIndexReindex:
def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self):
# GH#7774
index = date_range("2013-01-01", periods=3, tz="US/Eastern")
assert str(index.reindex([])[0].tz) == "US/Eastern"
assert str(index.reindex(np.array([]))[0].tz) == "US/Eastern"
Reported by Pylint.
Line: 16
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self):
# GH#7774
index = date_range("2013-01-01", periods=3, tz="US/Eastern")
assert str(index.reindex([])[0].tz) == "US/Eastern"
assert str(index.reindex(np.array([]))[0].tz) == "US/Eastern"
def test_reindex_with_same_tz_nearest(self):
# GH#32740
rng_a = date_range("2010-01-01", "2010-01-02", periods=24, tz="utc")
Reported by Bandit.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# GH#7774
index = date_range("2013-01-01", periods=3, tz="US/Eastern")
assert str(index.reindex([])[0].tz) == "US/Eastern"
assert str(index.reindex(np.array([]))[0].tz) == "US/Eastern"
def test_reindex_with_same_tz_nearest(self):
# GH#32740
rng_a = date_range("2010-01-01", "2010-01-02", periods=24, tz="utc")
rng_b = date_range("2010-01-01", "2010-01-02", periods=23, tz="utc")
Reported by Bandit.
Line: 19
Column: 5
assert str(index.reindex([])[0].tz) == "US/Eastern"
assert str(index.reindex(np.array([]))[0].tz) == "US/Eastern"
def test_reindex_with_same_tz_nearest(self):
# GH#32740
rng_a = date_range("2010-01-01", "2010-01-02", periods=24, tz="utc")
rng_b = date_range("2010-01-01", "2010-01-02", periods=23, tz="utc")
result1, result2 = rng_a.reindex(
rng_b, method="nearest", tolerance=timedelta(seconds=20)
Reported by Pylint.
Line: 19
Column: 5
assert str(index.reindex([])[0].tz) == "US/Eastern"
assert str(index.reindex(np.array([]))[0].tz) == "US/Eastern"
def test_reindex_with_same_tz_nearest(self):
# GH#32740
rng_a = date_range("2010-01-01", "2010-01-02", periods=24, tz="utc")
rng_b = date_range("2010-01-01", "2010-01-02", periods=23, tz="utc")
result1, result2 = rng_a.reindex(
rng_b, method="nearest", tolerance=timedelta(seconds=20)
Reported by Pylint.
pandas/tests/frame/methods/test_reorder_levels.py
8 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
MultiIndex,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
MultiIndex,
)
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestReorderLevels:
def test_reorder_levels(self, frame_or_series):
index = MultiIndex(
levels=[["bar"], ["one", "two", "three"], [0, 1]],
codes=[[0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2], [0, 1, 0, 1, 0, 1]],
names=["L0", "L1", "L2"],
Reported by Pylint.
Line: 12
Column: 5
class TestReorderLevels:
def test_reorder_levels(self, frame_or_series):
index = MultiIndex(
levels=[["bar"], ["one", "two", "three"], [0, 1]],
codes=[[0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2], [0, 1, 0, 1, 0, 1]],
names=["L0", "L1", "L2"],
)
Reported by Pylint.
Line: 12
Column: 5
class TestReorderLevels:
def test_reorder_levels(self, frame_or_series):
index = MultiIndex(
levels=[["bar"], ["one", "two", "three"], [0, 1]],
codes=[[0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2], [0, 1, 0, 1, 0, 1]],
names=["L0", "L1", "L2"],
)
Reported by Pylint.
Line: 18
Column: 9
codes=[[0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2], [0, 1, 0, 1, 0, 1]],
names=["L0", "L1", "L2"],
)
df = DataFrame({"A": np.arange(6), "B": np.arange(6)}, index=index)
obj = df if frame_or_series is DataFrame else df["A"]
# no change, position
result = obj.reorder_levels([0, 1, 2])
tm.assert_equal(obj, result)
Reported by Pylint.
Line: 53
Column: 5
result = obj.reorder_levels(["L0", "L0", "L0"])
tm.assert_equal(result, expected)
def test_reorder_levels_swaplevel_equivalence(
self, multiindex_year_month_day_dataframe_random_data
):
ymd = multiindex_year_month_day_dataframe_random_data
Reported by Pylint.
Line: 53
Column: 5
result = obj.reorder_levels(["L0", "L0", "L0"])
tm.assert_equal(result, expected)
def test_reorder_levels_swaplevel_equivalence(
self, multiindex_year_month_day_dataframe_random_data
):
ymd = multiindex_year_month_day_dataframe_random_data
Reported by Pylint.
pandas/tests/dtypes/cast/test_downcast.py
8 issues
Line: 4
Column: 1
import decimal
import numpy as np
import pytest
from pandas.core.dtypes.cast import maybe_downcast_to_dtype
from pandas import Series
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import decimal
import numpy as np
import pytest
from pandas.core.dtypes.cast import maybe_downcast_to_dtype
from pandas import Series
import pandas._testing as tm
Reported by Pylint.
Line: 36
Column: 1
np.array([decimal.Decimal(0.0)]),
"int64",
np.array([decimal.Decimal(0.0)]),
),
],
)
def test_downcast(arr, expected, dtype):
result = maybe_downcast_to_dtype(arr, dtype)
tm.assert_numpy_array_equal(result, expected)
Reported by Pylint.
Line: 44
Column: 1
tm.assert_numpy_array_equal(result, expected)
def test_downcast_booleans():
# see gh-16875: coercing of booleans.
ser = Series([True, True, False])
result = maybe_downcast_to_dtype(ser, np.dtype(np.float64))
expected = ser
Reported by Pylint.
Line: 53
Column: 1
tm.assert_series_equal(result, expected)
def test_downcast_conversion_no_nan(any_real_numpy_dtype):
dtype = any_real_numpy_dtype
expected = np.array([1, 2])
arr = np.array([1.0, 2.0], dtype=dtype)
result = maybe_downcast_to_dtype(arr, "infer")
Reported by Pylint.
Line: 62
Column: 1
tm.assert_almost_equal(result, expected, check_dtype=False)
def test_downcast_conversion_nan(float_numpy_dtype):
dtype = float_numpy_dtype
data = [1.0, 2.0, np.nan]
expected = np.array(data, dtype=dtype)
arr = np.array(data, dtype=dtype)
Reported by Pylint.
Line: 73
Column: 1
tm.assert_almost_equal(result, expected)
def test_downcast_conversion_empty(any_real_numpy_dtype):
dtype = any_real_numpy_dtype
arr = np.array([], dtype=dtype)
result = maybe_downcast_to_dtype(arr, np.dtype("int64"))
tm.assert_numpy_array_equal(result, np.array([], dtype=np.int64))
Reported by Pylint.
Line: 81
Column: 1
@pytest.mark.parametrize("klass", [np.datetime64, np.timedelta64])
def test_datetime_likes_nan(klass):
dtype = klass.__name__ + "[ns]"
arr = np.array([1, 2, np.nan])
exp = np.array([1, 2, klass("NaT")], dtype)
res = maybe_downcast_to_dtype(arr, dtype)
Reported by Pylint.
asv_bench/benchmarks/package.py
8 issues
Line: 14
Column: 13
# measurement of the import time we actually care about,
# without the subprocess or interpreter overhead
cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
p = subprocess.run(cmd, stderr=subprocess.PIPE)
line = p.stderr.splitlines()[-1]
field = line.split(b"|")[-2].strip()
total = int(field) # microseconds
return total
Reported by Pylint.
Line: 4
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
"""
Benchmarks for pandas at the package-level.
"""
import subprocess
import sys
class TimeImport:
def time_import(self):
Reported by Bandit.
Line: 8
Column: 1
import sys
class TimeImport:
def time_import(self):
# on py37+ we the "-X importtime" usage gives us a more precise
# measurement of the import time we actually care about,
# without the subprocess or interpreter overhead
cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
Reported by Pylint.
Line: 8
Column: 1
import sys
class TimeImport:
def time_import(self):
# on py37+ we the "-X importtime" usage gives us a more precise
# measurement of the import time we actually care about,
# without the subprocess or interpreter overhead
cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
Reported by Pylint.
Line: 9
Column: 5
class TimeImport:
def time_import(self):
# on py37+ we the "-X importtime" usage gives us a more precise
# measurement of the import time we actually care about,
# without the subprocess or interpreter overhead
cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
p = subprocess.run(cmd, stderr=subprocess.PIPE)
Reported by Pylint.
Line: 9
Column: 5
class TimeImport:
def time_import(self):
# on py37+ we the "-X importtime" usage gives us a more precise
# measurement of the import time we actually care about,
# without the subprocess or interpreter overhead
cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
p = subprocess.run(cmd, stderr=subprocess.PIPE)
Reported by Pylint.
Line: 14
Column: 9
# measurement of the import time we actually care about,
# without the subprocess or interpreter overhead
cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
p = subprocess.run(cmd, stderr=subprocess.PIPE)
line = p.stderr.splitlines()[-1]
field = line.split(b"|")[-2].strip()
total = int(field) # microseconds
return total
Reported by Pylint.
Line: 14
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
# measurement of the import time we actually care about,
# without the subprocess or interpreter overhead
cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
p = subprocess.run(cmd, stderr=subprocess.PIPE)
line = p.stderr.splitlines()[-1]
field = line.split(b"|")[-2].strip()
total = int(field) # microseconds
return total
Reported by Bandit.
pandas/io/excel/_util.py
8 issues
Line: 1
Column: 1
from __future__ import annotations
from typing import (
Any,
MutableMapping,
)
from pandas.compat._optional import import_optional_dependency
Reported by Pylint.
Line: 65
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
"xls": "xlwt",
"ods": "odf",
}
assert mode in ["reader", "writer"]
if mode == "writer":
# Prefer xlsxwriter over openpyxl if installed
xlsxwriter = import_optional_dependency("xlsxwriter", errors="warn")
if xlsxwriter:
_default_writers["xlsx"] = "xlsxwriter"
Reported by Bandit.
Line: 66
Column: 5
"ods": "odf",
}
assert mode in ["reader", "writer"]
if mode == "writer":
# Prefer xlsxwriter over openpyxl if installed
xlsxwriter = import_optional_dependency("xlsxwriter", errors="warn")
if xlsxwriter:
_default_writers["xlsx"] = "xlsxwriter"
return _default_writers[ext]
Reported by Pylint.
Line: 76
Column: 1
return _default_readers[ext]
def get_writer(engine_name):
try:
return _writers[engine_name]
except KeyError as err:
raise ValueError(f"No Excel writer '{engine_name}'") from err
Reported by Pylint.
Line: 83
Column: 1
raise ValueError(f"No Excel writer '{engine_name}'") from err
def _excel2num(x: str) -> int:
"""
Convert Excel column name like 'AB' to 0-based column index.
Parameters
----------
Reported by Pylint.
Line: 104
Column: 9
"""
index = 0
for c in x.upper().strip():
cp = ord(c)
if cp < ord("A") or cp > ord("Z"):
raise ValueError(f"Invalid column name: {x}")
Reported by Pylint.
Line: 105
Column: 9
index = 0
for c in x.upper().strip():
cp = ord(c)
if cp < ord("A") or cp > ord("Z"):
raise ValueError(f"Invalid column name: {x}")
index = index * 26 + cp - ord("A") + 1
Reported by Pylint.
Line: 177
Column: 1
return usecols
def validate_freeze_panes(freeze_panes):
if freeze_panes is not None:
if len(freeze_panes) == 2 and all(
isinstance(item, int) for item in freeze_panes
):
return True
Reported by Pylint.