The following issues were found
pandas/tests/series/methods/test_pct_change.py
19 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestSeriesPctChange:
def test_pct_change(self, datetime_series):
rs = datetime_series.pct_change(fill_method=None)
tm.assert_series_equal(rs, datetime_series / datetime_series.shift(1) - 1)
rs = datetime_series.pct_change(2)
Reported by Pylint.
Line: 12
Column: 5
class TestSeriesPctChange:
def test_pct_change(self, datetime_series):
rs = datetime_series.pct_change(fill_method=None)
tm.assert_series_equal(rs, datetime_series / datetime_series.shift(1) - 1)
rs = datetime_series.pct_change(2)
filled = datetime_series.fillna(method="pad")
Reported by Pylint.
Line: 12
Column: 5
class TestSeriesPctChange:
def test_pct_change(self, datetime_series):
rs = datetime_series.pct_change(fill_method=None)
tm.assert_series_equal(rs, datetime_series / datetime_series.shift(1) - 1)
rs = datetime_series.pct_change(2)
filled = datetime_series.fillna(method="pad")
Reported by Pylint.
Line: 13
Column: 9
class TestSeriesPctChange:
def test_pct_change(self, datetime_series):
rs = datetime_series.pct_change(fill_method=None)
tm.assert_series_equal(rs, datetime_series / datetime_series.shift(1) - 1)
rs = datetime_series.pct_change(2)
filled = datetime_series.fillna(method="pad")
tm.assert_series_equal(rs, filled / filled.shift(2) - 1)
Reported by Pylint.
Line: 16
Column: 9
rs = datetime_series.pct_change(fill_method=None)
tm.assert_series_equal(rs, datetime_series / datetime_series.shift(1) - 1)
rs = datetime_series.pct_change(2)
filled = datetime_series.fillna(method="pad")
tm.assert_series_equal(rs, filled / filled.shift(2) - 1)
rs = datetime_series.pct_change(fill_method="bfill", limit=1)
filled = datetime_series.fillna(method="bfill", limit=1)
Reported by Pylint.
Line: 20
Column: 9
filled = datetime_series.fillna(method="pad")
tm.assert_series_equal(rs, filled / filled.shift(2) - 1)
rs = datetime_series.pct_change(fill_method="bfill", limit=1)
filled = datetime_series.fillna(method="bfill", limit=1)
tm.assert_series_equal(rs, filled / filled.shift(1) - 1)
rs = datetime_series.pct_change(freq="5D")
filled = datetime_series.fillna(method="pad")
Reported by Pylint.
Line: 24
Column: 9
filled = datetime_series.fillna(method="bfill", limit=1)
tm.assert_series_equal(rs, filled / filled.shift(1) - 1)
rs = datetime_series.pct_change(freq="5D")
filled = datetime_series.fillna(method="pad")
tm.assert_series_equal(
rs, (filled / filled.shift(freq="5D") - 1).reindex_like(filled)
)
Reported by Pylint.
Line: 30
Column: 5
rs, (filled / filled.shift(freq="5D") - 1).reindex_like(filled)
)
def test_pct_change_with_duplicate_axis(self):
# GH#28664
common_idx = date_range("2019-11-14", periods=5, freq="D")
result = Series(range(5), common_idx).pct_change(freq="B")
# the reason that the expected should be like this is documented at PR 28681
Reported by Pylint.
pandas/tests/util/test_assert_categorical_equal.py
19 issues
Line: 1
Column: 1
import pytest
from pandas import Categorical
import pandas._testing as tm
@pytest.mark.parametrize(
"c",
[Categorical([1, 2, 3, 4]), Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4, 5])],
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import Categorical
import pandas._testing as tm
@pytest.mark.parametrize(
"c",
[Categorical([1, 2, 3, 4]), Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4, 5])],
Reported by Pylint.
Line: 10
Column: 1
@pytest.mark.parametrize(
"c",
[Categorical([1, 2, 3, 4]), Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4, 5])],
)
def test_categorical_equal(c):
tm.assert_categorical_equal(c, c)
@pytest.mark.parametrize("check_category_order", [True, False])
Reported by Pylint.
Line: 10
Column: 1
@pytest.mark.parametrize(
"c",
[Categorical([1, 2, 3, 4]), Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4, 5])],
)
def test_categorical_equal(c):
tm.assert_categorical_equal(c, c)
@pytest.mark.parametrize("check_category_order", [True, False])
Reported by Pylint.
Line: 16
Column: 1
@pytest.mark.parametrize("check_category_order", [True, False])
def test_categorical_equal_order_mismatch(check_category_order):
c1 = Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4])
c2 = Categorical([1, 2, 3, 4], categories=[4, 3, 2, 1])
kwargs = {"check_category_order": check_category_order}
if check_category_order:
Reported by Pylint.
Line: 17
Column: 5
@pytest.mark.parametrize("check_category_order", [True, False])
def test_categorical_equal_order_mismatch(check_category_order):
c1 = Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4])
c2 = Categorical([1, 2, 3, 4], categories=[4, 3, 2, 1])
kwargs = {"check_category_order": check_category_order}
if check_category_order:
msg = """Categorical\\.categories are different
Reported by Pylint.
Line: 18
Column: 5
@pytest.mark.parametrize("check_category_order", [True, False])
def test_categorical_equal_order_mismatch(check_category_order):
c1 = Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4])
c2 = Categorical([1, 2, 3, 4], categories=[4, 3, 2, 1])
kwargs = {"check_category_order": check_category_order}
if check_category_order:
msg = """Categorical\\.categories are different
Reported by Pylint.
Line: 33
Column: 1
tm.assert_categorical_equal(c1, c2, **kwargs)
def test_categorical_equal_categories_mismatch():
msg = """Categorical\\.categories are different
Categorical\\.categories values are different \\(25\\.0 %\\)
\\[left\\]: Int64Index\\(\\[1, 2, 3, 4\\], dtype='int64'\\)
\\[right\\]: Int64Index\\(\\[1, 2, 3, 5\\], dtype='int64'\\)"""
Reported by Pylint.
Line: 40
Column: 5
\\[left\\]: Int64Index\\(\\[1, 2, 3, 4\\], dtype='int64'\\)
\\[right\\]: Int64Index\\(\\[1, 2, 3, 5\\], dtype='int64'\\)"""
c1 = Categorical([1, 2, 3, 4])
c2 = Categorical([1, 2, 3, 5])
with pytest.raises(AssertionError, match=msg):
tm.assert_categorical_equal(c1, c2)
Reported by Pylint.
Line: 41
Column: 5
\\[right\\]: Int64Index\\(\\[1, 2, 3, 5\\], dtype='int64'\\)"""
c1 = Categorical([1, 2, 3, 4])
c2 = Categorical([1, 2, 3, 5])
with pytest.raises(AssertionError, match=msg):
tm.assert_categorical_equal(c1, c2)
Reported by Pylint.
pandas/tests/series/methods/test_value_counts.py
19 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Categorical,
CategoricalIndex,
Series,
)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Categorical,
CategoricalIndex,
Series,
)
Reported by Pylint.
Line: 13
Column: 1
import pandas._testing as tm
class TestSeriesValueCounts:
def test_value_counts_datetime(self):
# most dtypes are tested in tests/base
values = [
pd.Timestamp("2011-01-01 09:00"),
pd.Timestamp("2011-01-01 10:00"),
Reported by Pylint.
Line: 14
Column: 5
class TestSeriesValueCounts:
def test_value_counts_datetime(self):
# most dtypes are tested in tests/base
values = [
pd.Timestamp("2011-01-01 09:00"),
pd.Timestamp("2011-01-01 10:00"),
pd.Timestamp("2011-01-01 11:00"),
Reported by Pylint.
Line: 14
Column: 5
class TestSeriesValueCounts:
def test_value_counts_datetime(self):
# most dtypes are tested in tests/base
values = [
pd.Timestamp("2011-01-01 09:00"),
pd.Timestamp("2011-01-01 10:00"),
pd.Timestamp("2011-01-01 11:00"),
Reported by Pylint.
Line: 41
Column: 5
tm.assert_series_equal(ser.value_counts(normalize=True), exp)
tm.assert_series_equal(idx.value_counts(normalize=True), exp)
def test_value_counts_datetime_tz(self):
values = [
pd.Timestamp("2011-01-01 09:00", tz="US/Eastern"),
pd.Timestamp("2011-01-01 10:00", tz="US/Eastern"),
pd.Timestamp("2011-01-01 11:00", tz="US/Eastern"),
pd.Timestamp("2011-01-01 09:00", tz="US/Eastern"),
Reported by Pylint.
Line: 41
Column: 5
tm.assert_series_equal(ser.value_counts(normalize=True), exp)
tm.assert_series_equal(idx.value_counts(normalize=True), exp)
def test_value_counts_datetime_tz(self):
values = [
pd.Timestamp("2011-01-01 09:00", tz="US/Eastern"),
pd.Timestamp("2011-01-01 10:00", tz="US/Eastern"),
pd.Timestamp("2011-01-01 11:00", tz="US/Eastern"),
pd.Timestamp("2011-01-01 09:00", tz="US/Eastern"),
Reported by Pylint.
Line: 66
Column: 5
tm.assert_series_equal(ser.value_counts(normalize=True), exp)
tm.assert_series_equal(idx.value_counts(normalize=True), exp)
def test_value_counts_period(self):
values = [
pd.Period("2011-01", freq="M"),
pd.Period("2011-02", freq="M"),
pd.Period("2011-03", freq="M"),
pd.Period("2011-01", freq="M"),
Reported by Pylint.
Line: 66
Column: 5
tm.assert_series_equal(ser.value_counts(normalize=True), exp)
tm.assert_series_equal(idx.value_counts(normalize=True), exp)
def test_value_counts_period(self):
values = [
pd.Period("2011-01", freq="M"),
pd.Period("2011-02", freq="M"),
pd.Period("2011-03", freq="M"),
pd.Period("2011-01", freq="M"),
Reported by Pylint.
Line: 90
Column: 5
tm.assert_series_equal(ser.value_counts(normalize=True), exp)
tm.assert_series_equal(idx.value_counts(normalize=True), exp)
def test_value_counts_categorical_ordered(self):
# most dtypes are tested in tests/base
values = Categorical([1, 2, 3, 1, 1, 3], ordered=True)
exp_idx = CategoricalIndex([1, 3, 2], categories=[1, 2, 3], ordered=True)
exp = Series([3, 2, 1], index=exp_idx, name="xxx")
Reported by Pylint.
pandas/tests/indexes/timedeltas/test_timedelta_range.py
19 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Timedelta,
timedelta_range,
to_timedelta,
)
import pandas._testing as tm
Reported by Pylint.
Line: 92
Column: 16
def test_timedelta_range_infer_freq(self):
# https://github.com/pandas-dev/pandas/issues/35897
result = timedelta_range("0s", "1s", periods=31)
assert result.freq is None
Reported by Pylint.
Line: 92
Column: 16
def test_timedelta_range_infer_freq(self):
# https://github.com/pandas-dev/pandas/issues/35897
result = timedelta_range("0s", "1s", periods=31)
assert result.freq is None
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Timedelta,
timedelta_range,
to_timedelta,
)
import pandas._testing as tm
Reported by Pylint.
Line: 17
Column: 1
)
class TestTimedeltas:
def test_timedelta_range(self):
expected = to_timedelta(np.arange(5), unit="D")
result = timedelta_range("0 days", periods=5, freq="D")
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 18
Column: 5
class TestTimedeltas:
def test_timedelta_range(self):
expected = to_timedelta(np.arange(5), unit="D")
result = timedelta_range("0 days", periods=5, freq="D")
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 18
Column: 5
class TestTimedeltas:
def test_timedelta_range(self):
expected = to_timedelta(np.arange(5), unit="D")
result = timedelta_range("0 days", periods=5, freq="D")
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 42
Column: 5
@pytest.mark.parametrize(
"periods, freq", [(3, "2D"), (5, "D"), (6, "19H12T"), (7, "16H"), (9, "12H")]
)
def test_linspace_behavior(self, periods, freq):
# GH 20976
result = timedelta_range(start="0 days", end="4 days", periods=periods)
expected = timedelta_range(start="0 days", end="4 days", freq=freq)
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 42
Column: 5
@pytest.mark.parametrize(
"periods, freq", [(3, "2D"), (5, "D"), (6, "19H12T"), (7, "16H"), (9, "12H")]
)
def test_linspace_behavior(self, periods, freq):
# GH 20976
result = timedelta_range(start="0 days", end="4 days", periods=periods)
expected = timedelta_range(start="0 days", end="4 days", freq=freq)
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 49
Column: 5
expected = timedelta_range(start="0 days", end="4 days", freq=freq)
tm.assert_index_equal(result, expected)
def test_errors(self):
# not enough params
msg = (
"Of the four parameters: start, end, periods, and freq, "
"exactly three must be specified"
)
Reported by Pylint.
pandas/tests/strings/test_string_array.py
19 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas._libs import lib
from pandas import (
DataFrame,
Series,
_testing as tm,
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs import lib
from pandas import (
DataFrame,
Series,
_testing as tm,
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas._libs import lib
from pandas import (
DataFrame,
Series,
_testing as tm,
Reported by Pylint.
Line: 13
Column: 1
)
def test_string_array(nullable_string_dtype, any_string_method):
method_name, args, kwargs = any_string_method
if method_name == "decode":
pytest.skip("decode requires bytes.")
data = ["a", "bb", np.nan, "ccc"]
Reported by Pylint.
Line: 19
Column: 5
pytest.skip("decode requires bytes.")
data = ["a", "bb", np.nan, "ccc"]
a = Series(data, dtype=object)
b = Series(data, dtype=nullable_string_dtype)
expected = getattr(a.str, method_name)(*args, **kwargs)
result = getattr(b.str, method_name)(*args, **kwargs)
Reported by Pylint.
Line: 20
Column: 5
data = ["a", "bb", np.nan, "ccc"]
a = Series(data, dtype=object)
b = Series(data, dtype=nullable_string_dtype)
expected = getattr(a.str, method_name)(*args, **kwargs)
result = getattr(b.str, method_name)(*args, **kwargs)
if isinstance(expected, Series):
Reported by Pylint.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if expected.dtype == "object" and lib.is_string_array(
expected.dropna().values,
):
assert result.dtype == nullable_string_dtype
result = result.astype(object)
elif expected.dtype == "object" and lib.is_bool_array(
expected.values, skipna=True
):
Reported by Bandit.
Line: 35
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
elif expected.dtype == "object" and lib.is_bool_array(
expected.values, skipna=True
):
assert result.dtype == "boolean"
result = result.astype(object)
elif expected.dtype == "bool":
assert result.dtype == "boolean"
result = result.astype("bool")
Reported by Bandit.
Line: 39
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = result.astype(object)
elif expected.dtype == "bool":
assert result.dtype == "boolean"
result = result.astype("bool")
elif expected.dtype == "float" and expected.isna().any():
assert result.dtype == "Int64"
result = result.astype("float")
Reported by Bandit.
Line: 43
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = result.astype("bool")
elif expected.dtype == "float" and expected.isna().any():
assert result.dtype == "Int64"
result = result.astype("float")
elif isinstance(expected, DataFrame):
columns = expected.select_dtypes(include="object").columns
assert all(result[columns].dtypes == nullable_string_dtype)
Reported by Bandit.
pandas/tests/indexes/ranges/test_indexing.py
19 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import RangeIndex
import pandas._testing as tm
class TestGetIndexer:
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import RangeIndex
import pandas._testing as tm
class TestGetIndexer:
Reported by Pylint.
Line: 9
Column: 1
import pandas._testing as tm
class TestGetIndexer:
def test_get_indexer(self):
index = RangeIndex(start=0, stop=20, step=2)
target = RangeIndex(10)
indexer = index.get_indexer(target)
expected = np.array([0, -1, 1, -1, 2, -1, 3, -1, 4, -1], dtype=np.intp)
Reported by Pylint.
Line: 10
Column: 5
class TestGetIndexer:
def test_get_indexer(self):
index = RangeIndex(start=0, stop=20, step=2)
target = RangeIndex(10)
indexer = index.get_indexer(target)
expected = np.array([0, -1, 1, -1, 2, -1, 3, -1, 4, -1], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
Reported by Pylint.
Line: 10
Column: 5
class TestGetIndexer:
def test_get_indexer(self):
index = RangeIndex(start=0, stop=20, step=2)
target = RangeIndex(10)
indexer = index.get_indexer(target)
expected = np.array([0, -1, 1, -1, 2, -1, 3, -1, 4, -1], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
Reported by Pylint.
Line: 17
Column: 5
expected = np.array([0, -1, 1, -1, 2, -1, 3, -1, 4, -1], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
def test_get_indexer_pad(self):
index = RangeIndex(start=0, stop=20, step=2)
target = RangeIndex(10)
indexer = index.get_indexer(target, method="pad")
expected = np.array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
Reported by Pylint.
Line: 17
Column: 5
expected = np.array([0, -1, 1, -1, 2, -1, 3, -1, 4, -1], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
def test_get_indexer_pad(self):
index = RangeIndex(start=0, stop=20, step=2)
target = RangeIndex(10)
indexer = index.get_indexer(target, method="pad")
expected = np.array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
Reported by Pylint.
Line: 24
Column: 5
expected = np.array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
def test_get_indexer_backfill(self):
index = RangeIndex(start=0, stop=20, step=2)
target = RangeIndex(10)
indexer = index.get_indexer(target, method="backfill")
expected = np.array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
Reported by Pylint.
Line: 24
Column: 5
expected = np.array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
def test_get_indexer_backfill(self):
index = RangeIndex(start=0, stop=20, step=2)
target = RangeIndex(10)
indexer = index.get_indexer(target, method="backfill")
expected = np.array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
Reported by Pylint.
Line: 31
Column: 5
expected = np.array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
def test_get_indexer_limit(self):
# GH#28631
idx = RangeIndex(4)
target = RangeIndex(6)
result = idx.get_indexer(target, method="pad", limit=1)
expected = np.array([0, 1, 2, 3, 3, -1], dtype=np.intp)
Reported by Pylint.
pandas/tests/tslibs/test_array_to_datetime.py
18 issues
Line: 8
Column: 1
from dateutil.tz.tz import tzoffset
import numpy as np
import pytest
import pytz
from pandas._libs import (
iNaT,
tslib,
Reported by Pylint.
Line: 9
Column: 1
from dateutil.tz.tz import tzoffset
import numpy as np
import pytest
import pytz
from pandas._libs import (
iNaT,
tslib,
)
Reported by Pylint.
Line: 11
Column: 1
import pytest
import pytz
from pandas._libs import (
iNaT,
tslib,
)
from pandas.compat import np_array_datetime64_compat
Reported by Pylint.
Line: 1
Column: 1
from datetime import (
date,
datetime,
)
from dateutil.tz.tz import tzoffset
import numpy as np
import pytest
import pytz
Reported by Pylint.
Line: 36
Column: 1
[
"2013-09-16T00:00:00.000000000-0000",
"2013-09-17T00:00:00.000000000-0000",
],
),
],
)
def test_parsing_valid_dates(data, expected):
arr = np.array(data, dtype=object)
Reported by Pylint.
Line: 55
Column: 1
["2013-01-01T08:00:00.000000000+0800", 480],
["2012-12-31T16:00:00.000000000-0800", -480],
["12-31-2012 23:00:00-01:00", -60],
],
)
def test_parsing_timezone_offsets(dt_string, expected_tz):
# All of these datetime strings with offsets are equivalent
# to the same datetime after the timezone offset is added.
arr = np.array(["01-01-2013 00:00:00"], dtype=object)
Reported by Pylint.
Line: 67
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result, result_tz = tslib.array_to_datetime(arr)
tm.assert_numpy_array_equal(result, expected)
assert result_tz is pytz.FixedOffset(expected_tz)
def test_parsing_non_iso_timezone_offset():
dt_string = "01-01-2013T00:00:00.000000000+0000"
arr = np.array([dt_string], dtype=object)
Reported by Bandit.
Line: 70
Column: 1
assert result_tz is pytz.FixedOffset(expected_tz)
def test_parsing_non_iso_timezone_offset():
dt_string = "01-01-2013T00:00:00.000000000+0000"
arr = np.array([dt_string], dtype=object)
result, result_tz = tslib.array_to_datetime(arr)
expected = np.array([np.datetime64("2013-01-01 00:00:00.000000000")])
Reported by Pylint.
Line: 78
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
expected = np.array([np.datetime64("2013-01-01 00:00:00.000000000")])
tm.assert_numpy_array_equal(result, expected)
assert result_tz is pytz.FixedOffset(0)
def test_parsing_different_timezone_offsets():
# see gh-17697
data = ["2015-11-18 15:30:00+05:30", "2015-11-18 15:30:00+06:30"]
Reported by Bandit.
Line: 81
Column: 1
assert result_tz is pytz.FixedOffset(0)
def test_parsing_different_timezone_offsets():
# see gh-17697
data = ["2015-11-18 15:30:00+05:30", "2015-11-18 15:30:00+06:30"]
data = np.array(data, dtype=object)
result, result_tz = tslib.array_to_datetime(data)
Reported by Pylint.
pandas/tests/io/parser/test_index_col.py
18 issues
Line: 9
Column: 1
from io import StringIO
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Reported by Pylint.
Line: 20
Column: 1
@pytest.mark.parametrize("with_header", [True, False])
def test_index_col_named(all_parsers, with_header):
parser = all_parsers
no_header = """\
KORD1,19990127, 19:00:00, 18:56:00, 0.8100, 2.8100, 7.2000, 0.0000, 280.0000
KORD2,19990127, 20:00:00, 19:56:00, 0.0100, 2.2100, 7.2000, 0.0000, 260.0000
KORD3,19990127, 21:00:00, 20:56:00, -0.5900, 2.2100, 5.7000, 0.0000, 280.0000
Reported by Pylint.
Line: 45
Column: 1
parser.read_csv(StringIO(data), index_col="ID")
def test_index_col_named2(all_parsers):
parser = all_parsers
data = """\
1,2,3,4,hello
5,6,7,8,world
9,10,11,12,foo
Reported by Pylint.
Line: 63
Column: 1
tm.assert_frame_equal(result, expected)
def test_index_col_is_true(all_parsers):
# see gh-9798
data = "a,b\n1,2"
parser = all_parsers
msg = "The value of index_col couldn't be 'True'"
Reported by Pylint.
Line: 73
Column: 1
parser.read_csv(StringIO(data), index_col=True)
def test_infer_index_col(all_parsers):
data = """A,B,C
foo,1,2,3
bar,4,5,6
baz,7,8,9
"""
Reported by Pylint.
Line: 125
Column: 1
{
"columns": ["z"],
"index": MultiIndex.from_arrays([[]] * 2, names=["y", "x"]),
},
),
],
)
def test_index_col_empty_data(all_parsers, index_col, kwargs):
data = "x,y,z"
Reported by Pylint.
Line: 138
Column: 1
tm.assert_frame_equal(result, expected)
def test_empty_with_index_col_false(all_parsers):
# see gh-10413
data = "x,y"
parser = all_parsers
result = parser.read_csv(StringIO(data), index_col=False)
Reported by Pylint.
Line: 156
Column: 1
["", "bar"],
["foo", "bar"],
["NotReallyUnnamed", "Unnamed: 0"],
],
)
def test_multi_index_naming(all_parsers, index_names):
parser = all_parsers
# We don't want empty index names being replaced with "Unnamed: 0"
Reported by Pylint.
Line: 172
Column: 1
tm.assert_frame_equal(result, expected)
def test_multi_index_naming_not_all_at_beginning(all_parsers):
parser = all_parsers
data = ",Unnamed: 2,\na,c,1\na,d,2\nb,c,3\nb,d,4"
result = parser.read_csv(StringIO(data), index_col=[0, 2])
expected = DataFrame(
Reported by Pylint.
Line: 186
Column: 1
tm.assert_frame_equal(result, expected)
def test_no_multi_index_level_names_empty(all_parsers):
# GH 10984
parser = all_parsers
midx = MultiIndex.from_tuples([("A", 1, 2), ("A", 1, 2), ("B", 1, 2)])
expected = DataFrame(np.random.randn(3, 3), index=midx, columns=["x", "y", "z"])
with tm.ensure_clean() as path:
Reported by Pylint.
pandas/tests/series/methods/test_update.py
18 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
CategoricalDtype,
DataFrame,
NaT,
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
CategoricalDtype,
DataFrame,
NaT,
Reported by Pylint.
Line: 16
Column: 1
import pandas._testing as tm
class TestUpdate:
def test_update(self):
s = Series([1.5, np.nan, 3.0, 4.0, np.nan])
s2 = Series([np.nan, 3.5, np.nan, 5.0])
s.update(s2)
Reported by Pylint.
Line: 17
Column: 5
class TestUpdate:
def test_update(self):
s = Series([1.5, np.nan, 3.0, 4.0, np.nan])
s2 = Series([np.nan, 3.5, np.nan, 5.0])
s.update(s2)
expected = Series([1.5, 3.5, 3.0, 5.0, np.nan])
Reported by Pylint.
Line: 17
Column: 5
class TestUpdate:
def test_update(self):
s = Series([1.5, np.nan, 3.0, 4.0, np.nan])
s2 = Series([np.nan, 3.5, np.nan, 5.0])
s.update(s2)
expected = Series([1.5, 3.5, 3.0, 5.0, np.nan])
Reported by Pylint.
Line: 18
Column: 9
class TestUpdate:
def test_update(self):
s = Series([1.5, np.nan, 3.0, 4.0, np.nan])
s2 = Series([np.nan, 3.5, np.nan, 5.0])
s.update(s2)
expected = Series([1.5, 3.5, 3.0, 5.0, np.nan])
tm.assert_series_equal(s, expected)
Reported by Pylint.
Line: 19
Column: 9
class TestUpdate:
def test_update(self):
s = Series([1.5, np.nan, 3.0, 4.0, np.nan])
s2 = Series([np.nan, 3.5, np.nan, 5.0])
s.update(s2)
expected = Series([1.5, 3.5, 3.0, 5.0, np.nan])
tm.assert_series_equal(s, expected)
Reported by Pylint.
Line: 26
Column: 9
tm.assert_series_equal(s, expected)
# GH 3217
df = DataFrame([{"a": 1}, {"a": 3, "b": 2}])
df["c"] = np.nan
df["c"].update(Series(["foo"], index=[0]))
expected = DataFrame(
[[1, np.nan, "foo"], [3, 2.0, np.nan]], columns=["a", "b", "c"]
Reported by Pylint.
Line: 58
Column: 5
([(61,), (63,)], "int64", Series([10, (61,), 12])),
([(61,), (63,)], float, Series([10.0, (61,), 12.0])),
([(61,), (63,)], object, Series([10, (61,), 12])),
],
)
def test_update_dtypes(self, other, dtype, expected):
ser = Series([10, 11, 12], dtype=dtype)
other = Series(other, index=[1, 3])
Reported by Pylint.
Line: 58
Column: 5
([(61,), (63,)], "int64", Series([10, (61,), 12])),
([(61,), (63,)], float, Series([10.0, (61,), 12.0])),
([(61,), (63,)], object, Series([10, (61,), 12])),
],
)
def test_update_dtypes(self, other, dtype, expected):
ser = Series([10, 11, 12], dtype=dtype)
other = Series(other, index=[1, 3])
Reported by Pylint.
pandas/tests/indexes/timedeltas/test_join.py
18 issues
Line: 47
Column: 31
# GH#32157
tdi = timedelta_range("1 day", periods=10)
result = tdi[:5].join(tdi[5:], how="outer")
assert result.freq == tdi.freq
tm.assert_index_equal(result, tdi)
result = tdi[:5].join(tdi[6:], how="outer")
assert result.freq is None
expected = tdi.delete(5)
Reported by Pylint.
Line: 47
Column: 31
# GH#32157
tdi = timedelta_range("1 day", periods=10)
result = tdi[:5].join(tdi[5:], how="outer")
assert result.freq == tdi.freq
tm.assert_index_equal(result, tdi)
result = tdi[:5].join(tdi[6:], how="outer")
assert result.freq is None
expected = tdi.delete(5)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
from pandas import (
Index,
Timedelta,
timedelta_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestJoin:
def test_append_join_nondatetimeindex(self):
rng = timedelta_range("1 days", periods=10)
idx = Index(["a", "b", "c", "d"])
result = rng.append(idx)
Reported by Pylint.
Line: 12
Column: 5
class TestJoin:
def test_append_join_nondatetimeindex(self):
rng = timedelta_range("1 days", periods=10)
idx = Index(["a", "b", "c", "d"])
result = rng.append(idx)
assert isinstance(result[0], Timedelta)
Reported by Pylint.
Line: 12
Column: 5
class TestJoin:
def test_append_join_nondatetimeindex(self):
rng = timedelta_range("1 days", periods=10)
idx = Index(["a", "b", "c", "d"])
result = rng.append(idx)
assert isinstance(result[0], Timedelta)
Reported by Pylint.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
idx = Index(["a", "b", "c", "d"])
result = rng.append(idx)
assert isinstance(result[0], Timedelta)
# it works
rng.join(idx, how="outer")
def test_join_self(self, join_type):
Reported by Bandit.
Line: 22
Column: 5
# it works
rng.join(idx, how="outer")
def test_join_self(self, join_type):
index = timedelta_range("1 day", periods=10)
joined = index.join(index, how=join_type)
tm.assert_index_equal(index, joined)
def test_does_not_convert_mixed_integer(self):
Reported by Pylint.
Line: 22
Column: 5
# it works
rng.join(idx, how="outer")
def test_join_self(self, join_type):
index = timedelta_range("1 day", periods=10)
joined = index.join(index, how=join_type)
tm.assert_index_equal(index, joined)
def test_does_not_convert_mixed_integer(self):
Reported by Pylint.
Line: 27
Column: 5
joined = index.join(index, how=join_type)
tm.assert_index_equal(index, joined)
def test_does_not_convert_mixed_integer(self):
df = tm.makeCustomDataframe(
10,
10,
data_gen_f=lambda *args, **kwargs: np.random.randn(),
r_idx_type="i",
Reported by Pylint.