The following issues were found
pandas/tests/plotting/frame/test_frame_groupby.py
11 issues
Line: 4
Column: 1
""" Test cases for DataFrame.plot """
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import DataFrame
import pandas._testing as tm
Reported by Pylint.
Line: 23
Column: 9
mpl.rcdefaults()
self.tdf = tm.makeTimeDataFrame()
self.hexbin_df = DataFrame(
{
"A": np.random.uniform(size=20),
"B": np.random.uniform(size=20),
"C": np.arange(20) + np.random.uniform(size=20),
Reported by Pylint.
Line: 24
Column: 9
mpl.rcdefaults()
self.tdf = tm.makeTimeDataFrame()
self.hexbin_df = DataFrame(
{
"A": np.random.uniform(size=20),
"B": np.random.uniform(size=20),
"C": np.arange(20) + np.random.uniform(size=20),
}
Reported by Pylint.
Line: 16
Column: 1
@td.skip_if_no_mpl
class TestDataFramePlotsGroupby(TestPlotBase):
def setup_method(self, method):
TestPlotBase.setup_method(self, method)
import matplotlib as mpl
mpl.rcdefaults()
Reported by Pylint.
Line: 19
Column: 9
class TestDataFramePlotsGroupby(TestPlotBase):
def setup_method(self, method):
TestPlotBase.setup_method(self, method)
import matplotlib as mpl
mpl.rcdefaults()
self.tdf = tm.makeTimeDataFrame()
self.hexbin_df = DataFrame(
Reported by Pylint.
Line: 33
Column: 13
)
def _assert_ytickslabels_visibility(self, axes, expected):
for ax, exp in zip(axes, expected):
self._check_visible(ax.get_yticklabels(), visible=exp)
def _assert_xtickslabels_visibility(self, axes, expected):
for ax, exp in zip(axes, expected):
self._check_visible(ax.get_xticklabels(), visible=exp)
Reported by Pylint.
Line: 37
Column: 13
self._check_visible(ax.get_yticklabels(), visible=exp)
def _assert_xtickslabels_visibility(self, axes, expected):
for ax, exp in zip(axes, expected):
self._check_visible(ax.get_xticklabels(), visible=exp)
@pytest.mark.parametrize(
"kwargs, expected",
[
Reported by Pylint.
Line: 49
Column: 5
({"sharey": True}, [True, False, True, False]),
# sharey=False, all yticklabels should be visible
({"sharey": False}, [True, True, True, True]),
],
)
def test_groupby_boxplot_sharey(self, kwargs, expected):
# https://github.com/pandas-dev/pandas/issues/20968
# sharey can now be switched check whether the right
# pair of axes is turned on or off
Reported by Pylint.
Line: 55
Column: 9
# https://github.com/pandas-dev/pandas/issues/20968
# sharey can now be switched check whether the right
# pair of axes is turned on or off
df = DataFrame(
{
"a": [-1.43, -0.15, -3.70, -1.43, -0.14],
"b": [0.56, 0.84, 0.29, 0.56, 0.85],
"c": [0, 1, 2, 3, 1],
},
Reported by Pylint.
Line: 76
Column: 5
# sharex=True, xticklabels should be visible
# only for bottom plots
({"sharex": True}, [False, False, True, True]),
],
)
def test_groupby_boxplot_sharex(self, kwargs, expected):
# https://github.com/pandas-dev/pandas/issues/20968
# sharex can now be switched check whether the right
# pair of axes is turned on or off
Reported by Pylint.
pandas/tests/io/parser/test_mangle_dupes.py
11 issues
Line: 8
Column: 1
"""
from io import StringIO
import pytest
from pandas import DataFrame
import pandas._testing as tm
Reported by Pylint.
Line: 16
Column: 3
@pytest.mark.parametrize("kwargs", [{}, {"mangle_dupe_cols": True}])
def test_basic(all_parsers, kwargs):
# TODO: add test for condition "mangle_dupe_cols=False"
# once it is actually supported (gh-12935)
parser = all_parsers
data = "a,a,b,b,b\n1,2,3,4,5"
result = parser.read_csv(StringIO(data), sep=",", **kwargs)
Reported by Pylint.
Line: 106
Column: 58
),
],
)
def test_thorough_mangle_names(all_parsers, data, names, expected):
# see gh-17095
parser = all_parsers
with pytest.raises(ValueError, match="Duplicate names"):
parser.read_csv(StringIO(data), names=names)
Reported by Pylint.
Line: 15
Column: 1
@pytest.mark.parametrize("kwargs", [{}, {"mangle_dupe_cols": True}])
def test_basic(all_parsers, kwargs):
# TODO: add test for condition "mangle_dupe_cols=False"
# once it is actually supported (gh-12935)
parser = all_parsers
data = "a,a,b,b,b\n1,2,3,4,5"
Reported by Pylint.
Line: 27
Column: 1
tm.assert_frame_equal(result, expected)
def test_basic_names(all_parsers):
# See gh-7160
parser = all_parsers
data = "a,b,a\n0,1,2\n3,4,5"
expected = DataFrame([[0, 1, 2], [3, 4, 5]], columns=["a", "b", "a.1"])
Reported by Pylint.
Line: 38
Column: 1
tm.assert_frame_equal(result, expected)
def test_basic_names_raise(all_parsers):
# See gh-7160
parser = all_parsers
data = "0,1,2\n3,4,5"
with pytest.raises(ValueError, match="Duplicate names"):
Reported by Pylint.
Line: 63
Column: 1
DataFrame(
[[1, 2, 3, 4, 5, 6, 7]],
columns=["a", "a.1", "a.3", "a.1.1", "a.2", "a.2.1", "a.3.1"],
),
),
],
)
def test_thorough_mangle_columns(all_parsers, data, expected):
# see gh-17060
Reported by Pylint.
Line: 102
Column: 1
["1", "2", "3", "4", "5", "6", "7"],
],
columns=["a", "a.1", "a.3", "a.1.1", "a.2", "a.2.1", "a.3.1"],
),
),
],
)
def test_thorough_mangle_names(all_parsers, data, names, expected):
# see gh-17095
Reported by Pylint.
Line: 114
Column: 1
parser.read_csv(StringIO(data), names=names)
def test_mangled_unnamed_placeholders(all_parsers):
# xref gh-13017
orig_key = "0"
parser = all_parsers
orig_value = [1, 2, 3]
Reported by Pylint.
Line: 120
Column: 5
parser = all_parsers
orig_value = [1, 2, 3]
df = DataFrame({orig_key: orig_value})
# This test recursively updates `df`.
for i in range(3):
expected = DataFrame()
Reported by Pylint.
pandas/tests/plotting/test_common.py
11 issues
Line: 1
Column: 1
import pytest
import pandas.util._test_decorators as td
from pandas import DataFrame
from pandas.tests.plotting.common import (
TestPlotBase,
_check_plot_works,
_gen_two_subplots,
Reported by Pylint.
Line: 33
Column: 15
self._check_ticks_props(ax, ylabelsize=0)
def test__gen_two_subplots_with_ax(self):
fig = self.plt.gcf()
gen = _gen_two_subplots(f=lambda **kwargs: None, fig=fig, ax="test")
# On the first yield, no subplot should be added since ax was passed
next(gen)
assert fig.get_axes() == []
# On the second, the one axis should match fig.subplot(2, 1, 2)
Reported by Pylint.
Line: 1
Column: 1
import pytest
import pandas.util._test_decorators as td
from pandas import DataFrame
from pandas.tests.plotting.common import (
TestPlotBase,
_check_plot_works,
_gen_two_subplots,
Reported by Pylint.
Line: 16
Column: 1
@td.skip_if_no_mpl
class TestCommon(TestPlotBase):
def test__check_ticks_props(self):
# GH 34768
df = DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]})
ax = _check_plot_works(df.plot, rot=30)
ax.yaxis.set_tick_params(rotation=30)
Reported by Pylint.
Line: 17
Column: 5
@td.skip_if_no_mpl
class TestCommon(TestPlotBase):
def test__check_ticks_props(self):
# GH 34768
df = DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]})
ax = _check_plot_works(df.plot, rot=30)
ax.yaxis.set_tick_params(rotation=30)
msg = "expected 0.00000 but got "
Reported by Pylint.
Line: 19
Column: 9
class TestCommon(TestPlotBase):
def test__check_ticks_props(self):
# GH 34768
df = DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]})
ax = _check_plot_works(df.plot, rot=30)
ax.yaxis.set_tick_params(rotation=30)
msg = "expected 0.00000 but got "
with pytest.raises(AssertionError, match=msg):
self._check_ticks_props(ax, xrot=0)
Reported by Pylint.
Line: 20
Column: 9
def test__check_ticks_props(self):
# GH 34768
df = DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]})
ax = _check_plot_works(df.plot, rot=30)
ax.yaxis.set_tick_params(rotation=30)
msg = "expected 0.00000 but got "
with pytest.raises(AssertionError, match=msg):
self._check_ticks_props(ax, xrot=0)
with pytest.raises(AssertionError, match=msg):
Reported by Pylint.
Line: 32
Column: 5
with pytest.raises(AssertionError, match=msg):
self._check_ticks_props(ax, ylabelsize=0)
def test__gen_two_subplots_with_ax(self):
fig = self.plt.gcf()
gen = _gen_two_subplots(f=lambda **kwargs: None, fig=fig, ax="test")
# On the first yield, no subplot should be added since ax was passed
next(gen)
assert fig.get_axes() == []
Reported by Pylint.
Line: 37
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
gen = _gen_two_subplots(f=lambda **kwargs: None, fig=fig, ax="test")
# On the first yield, no subplot should be added since ax was passed
next(gen)
assert fig.get_axes() == []
# On the second, the one axis should match fig.subplot(2, 1, 2)
next(gen)
axes = fig.get_axes()
assert len(axes) == 1
assert axes[0].get_geometry() == (2, 1, 2)
Reported by Bandit.
Line: 41
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# On the second, the one axis should match fig.subplot(2, 1, 2)
next(gen)
axes = fig.get_axes()
assert len(axes) == 1
assert axes[0].get_geometry() == (2, 1, 2)
Reported by Bandit.
pandas/tests/io/pytables/test_retain_attributes.py
11 issues
Line: 3
Column: 1
from warnings import catch_warnings
import pytest
from pandas._libs.tslibs import Timestamp
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 1
Column: 1
from warnings import catch_warnings
import pytest
from pandas._libs.tslibs import Timestamp
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 23
Column: 1
pytestmark = pytest.mark.single
def test_retain_index_attributes(setup_path):
# GH 3499, losing frequency info on index recreation
df = DataFrame(
{"A": Series(range(3), index=date_range("2000-1-1", periods=3, freq="H"))}
)
Reported by Pylint.
Line: 26
Column: 5
def test_retain_index_attributes(setup_path):
# GH 3499, losing frequency info on index recreation
df = DataFrame(
{"A": Series(range(3), index=date_range("2000-1-1", periods=3, freq="H"))}
)
with ensure_clean_store(setup_path) as store:
_maybe_remove(store, "data")
Reported by Pylint.
Line: 39
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
for attr in ["freq", "tz", "name"]:
for idx in ["index", "columns"]:
assert getattr(getattr(df, idx), attr, None) == getattr(
getattr(result, idx), attr, None
)
# try to append a table with a different frequency
with catch_warnings(record=True):
Reported by Bandit.
Line: 54
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
store.append("data", df2)
assert store.get_storer("data").info["index"]["freq"] is None
# this is ok
_maybe_remove(store, "df2")
df2 = DataFrame(
{
Reported by Bandit.
Line: 79
Column: 1
@pytest.mark.filterwarnings(
"ignore:\\nthe :pandas.io.pytables.AttributeConflictWarning"
)
def test_retain_index_attributes2(setup_path):
with ensure_clean_path(setup_path) as path:
with catch_warnings(record=True):
Reported by Pylint.
Line: 85
Column: 13
with catch_warnings(record=True):
df = DataFrame(
{
"A": Series(
range(3), index=date_range("2000-1-1", periods=3, freq="H")
)
}
Reported by Pylint.
Line: 105
Column: 13
idx = date_range("2000-1-1", periods=3, freq="H")
idx.name = "foo"
df = DataFrame({"A": Series(range(3), index=idx)})
df.to_hdf(path, "data", mode="w", append=True)
assert read_hdf(path, "data").index.name == "foo"
with catch_warnings(record=True):
Reported by Pylint.
Line: 108
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
df = DataFrame({"A": Series(range(3), index=idx)})
df.to_hdf(path, "data", mode="w", append=True)
assert read_hdf(path, "data").index.name == "foo"
with catch_warnings(record=True):
idx2 = date_range("2001-1-1", periods=3, freq="H")
idx2.name = "bar"
Reported by Bandit.
pandas/tests/io/excel/test_odswriter.py
11 issues
Line: 3
Column: 1
import re
import pytest
import pandas._testing as tm
from pandas.io.excel import ExcelWriter
odf = pytest.importorskip("odf")
Reported by Pylint.
Line: 19
Column: 13
with tm.ensure_clean(ext) as f:
with pytest.raises(ValueError, match=msg):
ExcelWriter(f, engine="odf", mode="a")
@pytest.mark.parametrize("nan_inf_to_errors", [True, False])
def test_kwargs(ext, nan_inf_to_errors):
# GH 42286
Reported by Pylint.
Line: 30
Column: 18
with tm.ensure_clean(ext) as f:
msg = re.escape("Use of **kwargs is deprecated")
with tm.assert_produces_warning(FutureWarning, match=msg):
with ExcelWriter(f, engine="odf", **kwargs) as _:
pass
@pytest.mark.parametrize("nan_inf_to_errors", [True, False])
def test_engine_kwargs(ext, nan_inf_to_errors):
Reported by Pylint.
Line: 40
Column: 14
# odswriter doesn't utilize engine_kwargs, nothing to check except that it works
engine_kwargs = {"options": {"nan_inf_to_errors": nan_inf_to_errors}}
with tm.ensure_clean(ext) as f:
with ExcelWriter(f, engine="odf", engine_kwargs=engine_kwargs) as _:
pass
Reported by Pylint.
Line: 1
Column: 1
import re
import pytest
import pandas._testing as tm
from pandas.io.excel import ExcelWriter
odf = pytest.importorskip("odf")
Reported by Pylint.
Line: 14
Column: 1
pytestmark = pytest.mark.parametrize("ext", [".ods"])
def test_write_append_mode_raises(ext):
msg = "Append mode is not supported with odf!"
with tm.ensure_clean(ext) as f:
with pytest.raises(ValueError, match=msg):
ExcelWriter(f, engine="odf", mode="a")
Reported by Pylint.
Line: 17
Column: 34
def test_write_append_mode_raises(ext):
msg = "Append mode is not supported with odf!"
with tm.ensure_clean(ext) as f:
with pytest.raises(ValueError, match=msg):
ExcelWriter(f, engine="odf", mode="a")
@pytest.mark.parametrize("nan_inf_to_errors", [True, False])
Reported by Pylint.
Line: 23
Column: 1
@pytest.mark.parametrize("nan_inf_to_errors", [True, False])
def test_kwargs(ext, nan_inf_to_errors):
# GH 42286
# odswriter doesn't utilize kwargs, nothing to check except that it works
kwargs = {"options": {"nan_inf_to_errors": nan_inf_to_errors}}
with tm.ensure_clean(ext) as f:
msg = re.escape("Use of **kwargs is deprecated")
Reported by Pylint.
Line: 27
Column: 34
# GH 42286
# odswriter doesn't utilize kwargs, nothing to check except that it works
kwargs = {"options": {"nan_inf_to_errors": nan_inf_to_errors}}
with tm.ensure_clean(ext) as f:
msg = re.escape("Use of **kwargs is deprecated")
with tm.assert_produces_warning(FutureWarning, match=msg):
with ExcelWriter(f, engine="odf", **kwargs) as _:
pass
Reported by Pylint.
Line: 35
Column: 1
@pytest.mark.parametrize("nan_inf_to_errors", [True, False])
def test_engine_kwargs(ext, nan_inf_to_errors):
# GH 42286
# odswriter doesn't utilize engine_kwargs, nothing to check except that it works
engine_kwargs = {"options": {"nan_inf_to_errors": nan_inf_to_errors}}
with tm.ensure_clean(ext) as f:
with ExcelWriter(f, engine="odf", engine_kwargs=engine_kwargs) as _:
Reported by Pylint.
pandas/tests/io/excel/test_xlrd.py
11 issues
Line: 3
Column: 1
import io
import pytest
from pandas.compat._optional import import_optional_dependency
import pandas as pd
import pandas._testing as tm
from pandas.tests.io.excel import xlrd_version
Reported by Pylint.
Line: 1
Column: 1
import io
import pytest
from pandas.compat._optional import import_optional_dependency
import pandas as pd
import pandas._testing as tm
from pandas.tests.io.excel import xlrd_version
Reported by Pylint.
Line: 20
Column: 1
@pytest.fixture(autouse=True)
def skip_ods_and_xlsb_files(read_ext):
if read_ext == ".ods":
pytest.skip("Not valid for xlrd")
if read_ext == ".xlsb":
pytest.skip("Not valid for xlrd")
if read_ext in (".xlsx", ".xlsm") and xlrd_version >= Version("2"):
Reported by Pylint.
Line: 29
Column: 1
pytest.skip("Not valid for xlrd >= 2.0")
def test_read_xlrd_book(read_ext, frame):
df = frame
engine = "xlrd"
sheet_name = "SheetA"
Reported by Pylint.
Line: 30
Column: 5
def test_read_xlrd_book(read_ext, frame):
df = frame
engine = "xlrd"
sheet_name = "SheetA"
with tm.ensure_clean(read_ext) as pth:
Reported by Pylint.
Line: 39
Column: 48
df.to_excel(pth, sheet_name)
book = xlrd.open_workbook(pth)
with ExcelFile(book, engine=engine) as xl:
result = pd.read_excel(xl, sheet_name=sheet_name, index_col=0)
tm.assert_frame_equal(df, result)
result = pd.read_excel(book, sheet_name=sheet_name, engine=engine, index_col=0)
tm.assert_frame_equal(df, result)
Reported by Pylint.
Line: 47
Column: 1
tm.assert_frame_equal(df, result)
def test_excel_file_warning_with_xlsx_file(datapath):
# GH 29375
path = datapath("io", "data", "excel", "test1.xlsx")
has_openpyxl = import_optional_dependency("openpyxl", errors="ignore") is not None
if not has_openpyxl:
with tm.assert_produces_warning(
Reported by Pylint.
Line: 63
Column: 1
pd.read_excel(path, "Sheet1", engine=None)
def test_read_excel_warning_with_xlsx_file(datapath):
# GH 29375
path = datapath("io", "data", "excel", "test1.xlsx")
has_openpyxl = import_optional_dependency("openpyxl", errors="ignore") is not None
if not has_openpyxl:
if xlrd_version >= Version("2"):
Reported by Pylint.
Line: 93
Column: 1
b"\x09\x02\x06\x00\x00\x00\x10\x00",
b"\x09\x04\x06\x00\x00\x00\x10\x00",
b"\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1",
],
)
def test_read_old_xls_files(file_header):
# GH 41226
f = io.BytesIO(file_header)
assert inspect_excel_format(f) == "xls"
Reported by Pylint.
Line: 97
Column: 5
)
def test_read_old_xls_files(file_header):
# GH 41226
f = io.BytesIO(file_header)
assert inspect_excel_format(f) == "xls"
Reported by Pylint.
pandas/util/_print_versions.py
11 issues
Line: 138
Column: 5
def main() -> int:
from optparse import OptionParser
parser = OptionParser()
parser.add_option(
"-j",
"--json",
Reported by Pylint.
Line: 149
Column: 15
help="Save output as JSON into file, pass in '-' to output to stdout",
)
(options, args) = parser.parse_args()
if options.json == "-":
options.json = True
show_versions(as_json=options.json)
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
import codecs
import json
import locale
import os
import platform
import struct
import sys
Reported by Pylint.
Line: 24
Column: 5
Use vendored versioneer code to get git hash, which handles
git worktree correctly.
"""
from pandas._version import get_versions
versions = get_versions()
return versions["full-revisionid"]
Reported by Pylint.
Line: 117
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if as_json is True:
sys.stdout.writelines(json.dumps(j, indent=2))
else:
assert isinstance(as_json, str) # needed for mypy
with codecs.open(as_json, "wb", encoding="utf8") as f:
json.dump(j, f, indent=2)
else:
assert isinstance(sys_info["LOCALE"], dict) # needed for mypy
Reported by Bandit.
Line: 118
Column: 65
sys.stdout.writelines(json.dumps(j, indent=2))
else:
assert isinstance(as_json, str) # needed for mypy
with codecs.open(as_json, "wb", encoding="utf8") as f:
json.dump(j, f, indent=2)
else:
assert isinstance(sys_info["LOCALE"], dict) # needed for mypy
language_code = sys_info["LOCALE"]["language-code"]
Reported by Pylint.
Line: 122
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
json.dump(j, f, indent=2)
else:
assert isinstance(sys_info["LOCALE"], dict) # needed for mypy
language_code = sys_info["LOCALE"]["language-code"]
encoding = sys_info["LOCALE"]["encoding"]
sys_info["LOCALE"] = f"{language_code}.{encoding}"
maxlen = max(len(x) for x in deps)
Reported by Bandit.
Line: 130
Column: 16
maxlen = max(len(x) for x in deps)
print("\nINSTALLED VERSIONS")
print("------------------")
for k, v in sys_info.items():
print(f"{k:<{maxlen}}: {v}")
print("")
for k, v in deps.items():
print(f"{k:<{maxlen}}: {v}")
Reported by Pylint.
Line: 133
Column: 16
for k, v in sys_info.items():
print(f"{k:<{maxlen}}: {v}")
print("")
for k, v in deps.items():
print(f"{k:<{maxlen}}: {v}")
def main() -> int:
from optparse import OptionParser
Reported by Pylint.
Line: 137
Column: 1
print(f"{k:<{maxlen}}: {v}")
def main() -> int:
from optparse import OptionParser
parser = OptionParser()
parser.add_option(
"-j",
Reported by Pylint.
pandas/tests/io/generate_legacy_storage_files.py
10 issues
Line: 37
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b403-import-pickle
from datetime import timedelta
import os
import pickle
import platform as pl
import sys
import numpy as np
Reported by Bandit.
Line: 152
Column: 5
index["interval"] = interval_range(0, periods=10)
mi = {
"reg2": MultiIndex.from_tuples(
tuple(
zip(
*[
["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"],
Reported by Pylint.
Line: 288
Column: 1
}
def create_pickle_data():
data = create_data()
return data
Reported by Pylint.
Line: 294
Column: 1
return data
def platform_name():
return "_".join(
[
str(pandas.__version__),
str(pl.machine()),
str(pl.system().lower()),
Reported by Pylint.
Line: 305
Column: 1
)
def write_legacy_pickles(output_dir):
version = pandas.__version__
print(
"This script generates a storage file for the current arch, system, "
Reported by Pylint.
Line: 319
Column: 55
pth = f"{platform_name()}.pickle"
with open(os.path.join(output_dir, pth), "wb") as fh:
pickle.dump(create_pickle_data(), fh, pickle.DEFAULT_PROTOCOL)
print(f"created pickle file: {pth}")
Reported by Pylint.
Line: 325
Column: 1
print(f"created pickle file: {pth}")
def write_legacy_file():
# force our cwd to be the first searched
sys.path.insert(0, ".")
if not (3 <= len(sys.argv) <= 4):
exit(
Reported by Pylint.
Line: 329
Column: 1
# force our cwd to be the first searched
sys.path.insert(0, ".")
if not (3 <= len(sys.argv) <= 4):
exit(
"Specify output directory and storage type: generate_legacy_"
"storage_files.py <output_dir> <storage_type> "
)
Reported by Pylint.
Line: 330
Column: 9
sys.path.insert(0, ".")
if not (3 <= len(sys.argv) <= 4):
exit(
"Specify output directory and storage type: generate_legacy_"
"storage_files.py <output_dir> <storage_type> "
)
output_dir = str(sys.argv[1])
Reported by Pylint.
Line: 341
Column: 9
if storage_type == "pickle":
write_legacy_pickles(output_dir=output_dir)
else:
exit("storage_type must be one of {'pickle'}")
if __name__ == "__main__":
write_legacy_file()
Reported by Pylint.
pandas/tests/io/parser/test_quoting.py
10 issues
Line: 9
Column: 1
import csv
from io import StringIO
import pytest
from pandas.errors import ParserError
from pandas import DataFrame
import pandas._testing as tm
Reported by Pylint.
Line: 26
Column: 1
"quotechar must be set if quoting enabled",
),
({"quotechar": 2}, '"quotechar" must be string, not int'),
],
)
def test_bad_quote_char(all_parsers, kwargs, msg):
data = "1,2,3"
parser = all_parsers
Reported by Pylint.
Line: 41
Column: 1
[
("foo", '"quoting" must be an integer'),
(5, 'bad "quoting" value'), # quoting must be in the range [0, 3]
],
)
def test_bad_quoting(all_parsers, quoting, msg):
data = "1,2,3"
parser = all_parsers
Reported by Pylint.
Line: 51
Column: 1
parser.read_csv(StringIO(data), quoting=quoting)
def test_quote_char_basic(all_parsers):
parser = all_parsers
data = 'a,b,c\n1,2,"cat"'
expected = DataFrame([[1, 2, "cat"]], columns=["a", "b", "c"])
result = parser.read_csv(StringIO(data), quotechar='"')
Reported by Pylint.
Line: 61
Column: 1
@pytest.mark.parametrize("quote_char", ["~", "*", "%", "$", "@", "P"])
def test_quote_char_various(all_parsers, quote_char):
parser = all_parsers
expected = DataFrame([[1, 2, "cat"]], columns=["a", "b", "c"])
data = 'a,b,c\n1,2,"cat"'
new_data = data.replace('"', quote_char)
Reported by Pylint.
Line: 74
Column: 1
@pytest.mark.parametrize("quoting", [csv.QUOTE_MINIMAL, csv.QUOTE_NONE])
@pytest.mark.parametrize("quote_char", ["", None])
def test_null_quote_char(all_parsers, quoting, quote_char):
kwargs = {"quotechar": quote_char, "quoting": quoting}
data = "a,b,c\n1,2,3"
parser = all_parsers
if quoting != csv.QUOTE_NONE:
Reported by Pylint.
Line: 105
Column: 1
# QUOTE_NONNUMERIC tells the reader to cast
# all non-quoted fields to float
({"quotechar": '"', "quoting": csv.QUOTE_NONNUMERIC}, [[1.0, 2.0, "foo"]]),
],
)
def test_quoting_various(all_parsers, kwargs, exp_data):
data = '1,2,"foo"'
parser = all_parsers
columns = ["a", "b", "c"]
Reported by Pylint.
Line: 119
Column: 1
@pytest.mark.parametrize(
"doublequote,exp_data", [(True, [[3, '4 " 5']]), (False, [[3, '4 " 5"']])]
)
def test_double_quote(all_parsers, doublequote, exp_data):
parser = all_parsers
data = 'a,b\n3,"4 "" 5"'
result = parser.read_csv(StringIO(data), quotechar='"', doublequote=doublequote)
Reported by Pylint.
Line: 130
Column: 1
@pytest.mark.parametrize("quotechar", ['"', "\u0001"])
def test_quotechar_unicode(all_parsers, quotechar):
# see gh-14477
data = "a\n1"
parser = all_parsers
expected = DataFrame({"a": [1]})
Reported by Pylint.
Line: 141
Column: 1
@pytest.mark.parametrize("balanced", [True, False])
def test_unbalanced_quoting(all_parsers, balanced):
# see gh-22789.
parser = all_parsers
data = 'a,b,c\n1,2,"3'
if balanced:
Reported by Pylint.
pandas/tests/reshape/test_pivot_multilevel.py
10 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Index,
Int64Index,
MultiIndex,
)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Index,
Int64Index,
MultiIndex,
)
Reported by Pylint.
Line: 82
Column: 1
),
MultiIndex.from_tuples(
[(1, 1), (1, 2), (2, 1), (2, 2)], names=["lev1", "lev2"]
),
),
],
)
def test_pivot_list_like_index(
input_index,
Reported by Pylint.
Line: 82
Column: 1
),
MultiIndex.from_tuples(
[(1, 1), (1, 2), (2, 1), (2, 2)], names=["lev1", "lev2"]
),
),
],
)
def test_pivot_list_like_index(
input_index,
Reported by Pylint.
Line: 95
Column: 5
expected_index,
):
# GH 21425, test when index is given a list
df = pd.DataFrame(
{
"lev1": [1, 1, 1, 1, 2, 2, 2, 2],
"lev2": [1, 1, 2, 2, 1, 1, 2, 2],
"lev3": [1, 2, 1, 2, 1, 2, 1, 2],
"lev4": [1, 2, 3, 4, 5, 6, 7, 8],
Reported by Pylint.
Line: 169
Column: 1
),
MultiIndex.from_tuples(
[(1, 1), (1, 2), (2, 1), (2, 2)], names=["lev1", "lev2"]
),
),
],
)
def test_pivot_list_like_columns(
input_index,
Reported by Pylint.
Line: 169
Column: 1
),
MultiIndex.from_tuples(
[(1, 1), (1, 2), (2, 1), (2, 2)], names=["lev1", "lev2"]
),
),
],
)
def test_pivot_list_like_columns(
input_index,
Reported by Pylint.
Line: 182
Column: 5
expected_index,
):
# GH 21425, test when columns is given a list
df = pd.DataFrame(
{
"lev1": [1, 1, 1, 1, 2, 2, 2, 2],
"lev2": [1, 1, 2, 2, 1, 1, 2, 2],
"lev3": [1, 2, 1, 2, 1, 2, 1, 2],
"lev4": [1, 2, 3, 4, 5, 6, 7, 8],
Reported by Pylint.
Line: 199
Column: 1
tm.assert_frame_equal(result, expected)
def test_pivot_multiindexed_rows_and_cols(using_array_manager):
# GH 36360
df = pd.DataFrame(
data=np.arange(12).reshape(4, 3),
columns=MultiIndex.from_tuples(
Reported by Pylint.
Line: 202
Column: 5
def test_pivot_multiindexed_rows_and_cols(using_array_manager):
# GH 36360
df = pd.DataFrame(
data=np.arange(12).reshape(4, 3),
columns=MultiIndex.from_tuples(
[(0, 0), (0, 1), (0, 2)], names=["col_L0", "col_L1"]
),
index=MultiIndex.from_tuples(
Reported by Pylint.