The following issues were found
pandas/tests/indexes/period/methods/test_fillna.py
5 issues
Line: 1
Column: 1
from pandas import (
Index,
NaT,
Period,
PeriodIndex,
)
import pandas._testing as tm
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestFillNA:
def test_fillna_period(self):
# GH#11343
idx = PeriodIndex(["2011-01-01 09:00", NaT, "2011-01-01 11:00"], freq="H")
exp = PeriodIndex(
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestFillNA:
def test_fillna_period(self):
# GH#11343
idx = PeriodIndex(["2011-01-01 09:00", NaT, "2011-01-01 11:00"], freq="H")
exp = PeriodIndex(
Reported by Pylint.
Line: 11
Column: 5
class TestFillNA:
def test_fillna_period(self):
# GH#11343
idx = PeriodIndex(["2011-01-01 09:00", NaT, "2011-01-01 11:00"], freq="H")
exp = PeriodIndex(
["2011-01-01 09:00", "2011-01-01 10:00", "2011-01-01 11:00"], freq="H"
Reported by Pylint.
Line: 11
Column: 5
class TestFillNA:
def test_fillna_period(self):
# GH#11343
idx = PeriodIndex(["2011-01-01 09:00", NaT, "2011-01-01 11:00"], freq="H")
exp = PeriodIndex(
["2011-01-01 09:00", "2011-01-01 10:00", "2011-01-01 11:00"], freq="H"
Reported by Pylint.
pandas/tests/indexes/period/methods/test_factorize.py
5 issues
Line: 1
Column: 1
import numpy as np
from pandas import PeriodIndex
import pandas._testing as tm
class TestFactorize:
def test_factorize(self):
idx1 = PeriodIndex(
Reported by Pylint.
Line: 7
Column: 1
import pandas._testing as tm
class TestFactorize:
def test_factorize(self):
idx1 = PeriodIndex(
["2014-01", "2014-01", "2014-02", "2014-02", "2014-03", "2014-03"], freq="M"
)
Reported by Pylint.
Line: 7
Column: 1
import pandas._testing as tm
class TestFactorize:
def test_factorize(self):
idx1 = PeriodIndex(
["2014-01", "2014-01", "2014-02", "2014-02", "2014-03", "2014-03"], freq="M"
)
Reported by Pylint.
Line: 8
Column: 5
class TestFactorize:
def test_factorize(self):
idx1 = PeriodIndex(
["2014-01", "2014-01", "2014-02", "2014-02", "2014-03", "2014-03"], freq="M"
)
exp_arr = np.array([0, 0, 1, 1, 2, 2], dtype=np.intp)
Reported by Pylint.
Line: 8
Column: 5
class TestFactorize:
def test_factorize(self):
idx1 = PeriodIndex(
["2014-01", "2014-01", "2014-02", "2014-02", "2014-03", "2014-03"], freq="M"
)
exp_arr = np.array([0, 0, 1, 1, 2, 2], dtype=np.intp)
Reported by Pylint.
pandas/tests/window/moments/conftest.py
5 issues
Line: 4
Column: 1
from datetime import datetime
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
bdate_range,
Reported by Pylint.
Line: 20
Column: 5
arr = np.random.randn(100)
locs = np.arange(20, 40)
arr[locs] = np.NaN
series = Series(arr, index=bdate_range(datetime(2009, 1, 1), periods=100))
return series
@pytest.fixture
def frame():
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
bdate_range,
Reported by Pylint.
Line: 167
Column: 5
DataFrame(np.arange(25).reshape((5, 5)), columns=["a", "b", 99, "d", "d"]),
] + [DataFrame(s) for s in create_series()]
def is_constant(x):
values = x.values.ravel("K")
return len(set(values[notna(values)])) == 1
def no_nans(x):
return x.notna().all().all()
Reported by Pylint.
Line: 171
Column: 5
values = x.values.ravel("K")
return len(set(values[notna(values)])) == 1
def no_nans(x):
return x.notna().all().all()
# data is a tuple(object, is_constant, no_nans)
data = create_series() + create_dataframes()
Reported by Pylint.
scripts/tests/test_use_pd_array_in_core.py
5 issues
Line: 1
Column: 1
import pytest
from scripts.use_pd_array_in_core import use_pd_array
BAD_FILE_0 = "import pandas as pd\npd.array"
BAD_FILE_1 = "\nfrom pandas import array"
GOOD_FILE_0 = "from pandas import array as pd_array"
GOOD_FILE_1 = "from pandas.core.construction import array as pd_array"
PATH = "t.py"
Reported by Pylint.
Line: 1
Column: 1
import pytest
from scripts.use_pd_array_in_core import use_pd_array
BAD_FILE_0 = "import pandas as pd\npd.array"
BAD_FILE_1 = "\nfrom pandas import array"
GOOD_FILE_0 = "from pandas import array as pd_array"
GOOD_FILE_1 = "from pandas.core.construction import array as pd_array"
PATH = "t.py"
Reported by Pylint.
Line: 13
Column: 1
@pytest.mark.parametrize("content", [BAD_FILE_0, BAD_FILE_1])
def test_inconsistent_usage(content, capsys):
result_msg = (
"t.py:2:0: Don't use pd.array in core, import array as pd_array instead\n"
)
with pytest.raises(SystemExit, match=None):
use_pd_array(content, PATH)
Reported by Pylint.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
with pytest.raises(SystemExit, match=None):
use_pd_array(content, PATH)
expected_msg, _ = capsys.readouterr()
assert result_msg == expected_msg
@pytest.mark.parametrize("content", [GOOD_FILE_0, GOOD_FILE_1])
def test_consistent_usage(content):
# should not raise
Reported by Bandit.
Line: 24
Column: 1
@pytest.mark.parametrize("content", [GOOD_FILE_0, GOOD_FILE_1])
def test_consistent_usage(content):
# should not raise
use_pd_array(content, PATH)
Reported by Pylint.
pandas/tests/tseries/offsets/conftest.py
4 issues
Line: 1
Column: 1
import pytest
from pandas._libs.tslibs.offsets import MonthOffset
import pandas.tseries.offsets as offsets
@pytest.fixture(params=[getattr(offsets, o) for o in offsets.__all__])
def offset_types(request):
Reported by Pylint.
Line: 3
Column: 1
import pytest
from pandas._libs.tslibs.offsets import MonthOffset
import pandas.tseries.offsets as offsets
@pytest.fixture(params=[getattr(offsets, o) for o in offsets.__all__])
def offset_types(request):
Reported by Pylint.
Line: 3
Column: 1
import pytest
from pandas._libs.tslibs.offsets import MonthOffset
import pandas.tseries.offsets as offsets
@pytest.fixture(params=[getattr(offsets, o) for o in offsets.__all__])
def offset_types(request):
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas._libs.tslibs.offsets import MonthOffset
import pandas.tseries.offsets as offsets
@pytest.fixture(params=[getattr(offsets, o) for o in offsets.__all__])
def offset_types(request):
Reported by Pylint.
pandas/tests/series/indexing/test_take.py
4 issues
Line: 1
Column: 1
import pytest
import pandas as pd
from pandas import Series
import pandas._testing as tm
def test_take():
ser = Series([-1, 5, 6, 2, 4])
Reported by Pylint.
Line: 1
Column: 1
import pytest
import pandas as pd
from pandas import Series
import pandas._testing as tm
def test_take():
ser = Series([-1, 5, 6, 2, 4])
Reported by Pylint.
Line: 8
Column: 1
import pandas._testing as tm
def test_take():
ser = Series([-1, 5, 6, 2, 4])
actual = ser.take([1, 3, 4])
expected = Series([5, 2, 4], index=[1, 3, 4])
tm.assert_series_equal(actual, expected)
Reported by Pylint.
Line: 26
Column: 1
ser.take([2, 5])
def test_take_categorical():
# https://github.com/pandas-dev/pandas/issues/20664
ser = Series(pd.Categorical(["a", "b", "c"]))
result = ser.take([-2, -2, 0])
expected = Series(
pd.Categorical(["b", "b", "a"], categories=["a", "b", "c"]), index=[1, 1, 0]
Reported by Pylint.
pandas/tests/io/json/test_deprecated_kwargs.py
4 issues
Line: 11
Column: 1
from pandas.io.json import read_json
def test_deprecated_kwargs():
df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2])
buf = df.to_json(orient="split")
with tm.assert_produces_warning(FutureWarning):
tm.assert_frame_equal(df, read_json(buf, "split"))
buf = df.to_json(orient="columns")
Reported by Pylint.
Line: 12
Column: 5
def test_deprecated_kwargs():
df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2])
buf = df.to_json(orient="split")
with tm.assert_produces_warning(FutureWarning):
tm.assert_frame_equal(df, read_json(buf, "split"))
buf = df.to_json(orient="columns")
with tm.assert_produces_warning(FutureWarning):
Reported by Pylint.
Line: 24
Column: 1
tm.assert_frame_equal(df, read_json(buf, "index"))
def test_good_kwargs():
df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2])
with tm.assert_produces_warning(None):
tm.assert_frame_equal(df, read_json(df.to_json(orient="split"), orient="split"))
tm.assert_frame_equal(
df, read_json(df.to_json(orient="columns"), orient="columns")
Reported by Pylint.
Line: 25
Column: 5
def test_good_kwargs():
df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2])
with tm.assert_produces_warning(None):
tm.assert_frame_equal(df, read_json(df.to_json(orient="split"), orient="split"))
tm.assert_frame_equal(
df, read_json(df.to_json(orient="columns"), orient="columns")
)
Reported by Pylint.
pandas/tests/io/test_date_converters.py
4 issues
Line: 1
Column: 1
from datetime import datetime
import numpy as np
import pandas._testing as tm
import pandas.io.date_converters as conv
Reported by Pylint.
Line: 10
Column: 1
import pandas.io.date_converters as conv
def test_parse_date_time():
dates = np.array(["2007/1/3", "2008/2/4"], dtype=object)
times = np.array(["05:07:09", "06:08:00"], dtype=object)
expected = np.array([datetime(2007, 1, 3, 5, 7, 9), datetime(2008, 2, 4, 6, 8, 0)])
with tm.assert_produces_warning(FutureWarning):
Reported by Pylint.
Line: 20
Column: 1
tm.assert_numpy_array_equal(result, expected)
def test_parse_date_fields():
days = np.array([3, 4])
months = np.array([1, 2])
years = np.array([2007, 2008])
expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
Reported by Pylint.
Line: 31
Column: 1
tm.assert_numpy_array_equal(result, expected)
def test_parse_all_fields():
hours = np.array([5, 6])
minutes = np.array([7, 8])
seconds = np.array([9, 0])
days = np.array([3, 4])
Reported by Pylint.
pandas/tests/io/parser/common/test_data_list.py
4 issues
Line: 14
Column: 1
from pandas.io.parsers import TextParser
def test_read_data_list(all_parsers):
parser = all_parsers
kwargs = {"index_col": 0}
data = "A,B,C\nfoo,1,2,3\nbar,4,5,6"
data_list = [["A", "B", "C"], ["foo", "1", "2", "3"], ["bar", "4", "5", "6"]]
Reported by Pylint.
Line: 28
Column: 1
tm.assert_frame_equal(result, expected)
def test_reader_list(all_parsers):
data = """index,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
qux,12,13,14,15
Reported by Pylint.
Line: 51
Column: 1
tm.assert_frame_equal(chunks[2], expected[4:])
def test_reader_list_skiprows(all_parsers):
data = """index,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
qux,12,13,14,15
Reported by Pylint.
Line: 72
Column: 1
tm.assert_frame_equal(chunks[0], expected[1:3])
def test_read_csv_parse_simple_list(all_parsers):
parser = all_parsers
data = """foo
bar baz
qux foo
foo
Reported by Pylint.
pandas/tests/io/parser/common/test_inf.py
4 issues
Line: 8
Column: 1
from io import StringIO
import numpy as np
import pytest
from pandas import (
DataFrame,
option_context,
)
Reported by Pylint.
Line: 18
Column: 1
@pytest.mark.parametrize("na_filter", [True, False])
def test_inf_parsing(all_parsers, na_filter):
parser = all_parsers
data = """\
,A
a,inf
b,-inf
Reported by Pylint.
Line: 41
Column: 1
@pytest.mark.parametrize("na_filter", [True, False])
def test_infinity_parsing(all_parsers, na_filter):
parser = all_parsers
data = """\
,A
a,Infinity
b,-Infinity
Reported by Pylint.
Line: 57
Column: 1
tm.assert_frame_equal(result, expected)
def test_read_csv_with_use_inf_as_na(all_parsers):
# https://github.com/pandas-dev/pandas/issues/35493
parser = all_parsers
data = "1.0\nNaN\n3.0"
with option_context("use_inf_as_na", True):
result = parser.read_csv(StringIO(data), header=None)
Reported by Pylint.