The following issues were found
pandas/tests/extension/json/array.py
21 issues
Line: 66
Column: 44
dtype = JSONDtype()
__array_priority__ = 1000
def __init__(self, values, dtype=None, copy=False):
for val in values:
if not isinstance(val, self.dtype.type):
raise TypeError("All values must be of type " + str(self.dtype.type))
self.data = values
Reported by Pylint.
Line: 66
Column: 32
dtype = JSONDtype()
__array_priority__ = 1000
def __init__(self, values, dtype=None, copy=False):
for val in values:
if not isinstance(val, self.dtype.type):
raise TypeError("All values must be of type " + str(self.dtype.type))
self.data = values
Reported by Pylint.
Line: 80
Column: 5
# self._values = self.values = self.data
@classmethod
def _from_sequence(cls, scalars, dtype=None, copy=False):
return cls(scalars)
@classmethod
def _from_factorized(cls, values, original):
return cls([UserDict(x) for x in values if x != ()])
Reported by Pylint.
Line: 80
Column: 50
# self._values = self.values = self.data
@classmethod
def _from_sequence(cls, scalars, dtype=None, copy=False):
return cls(scalars)
@classmethod
def _from_factorized(cls, values, original):
return cls([UserDict(x) for x in values if x != ()])
Reported by Pylint.
Line: 80
Column: 38
# self._values = self.values = self.data
@classmethod
def _from_sequence(cls, scalars, dtype=None, copy=False):
return cls(scalars)
@classmethod
def _from_factorized(cls, values, original):
return cls([UserDict(x) for x in values if x != ()])
Reported by Pylint.
Line: 153
Column: 5
def isna(self):
return np.array([x == self.dtype.na_value for x in self.data], dtype=bool)
def take(self, indexer, allow_fill=False, fill_value=None):
# re-implement here, since NumPy has trouble setting
# sized objects like UserDicts into scalar slots of
# an ndarary.
indexer = np.asarray(indexer)
msg = (
Reported by Pylint.
Line: 200
Column: 20
return self
elif isinstance(dtype, StringDtype):
value = self.astype(str) # numpy doesn'y like nested dicts
return dtype.construct_array_type()._from_sequence(value, copy=False)
return np.array([dict(x) for x in self], dtype=dtype, copy=copy)
def unique(self):
# Parent method doesn't work since np.array will try to infer
Reported by Pylint.
Line: 228
Column: 3
def make_data():
# TODO: Use a regular dict. See _NDFrameIndexer._setitem_with_indexer
return [
UserDict(
[
(random.choice(string.ascii_letters), random.randint(0, 100))
for _ in range(random.randint(0, 10))
Reported by Pylint.
Line: 45
Column: 1
from pandas.api.types import is_bool_dtype
class JSONDtype(ExtensionDtype):
type = abc.Mapping
name = "json"
na_value: Mapping[str, Any] = UserDict()
@classmethod
Reported by Pylint.
Line: 62
Column: 1
return JSONArray
class JSONArray(ExtensionArray):
dtype = JSONDtype()
__array_priority__ = 1000
def __init__(self, values, dtype=None, copy=False):
for val in values:
Reported by Pylint.
pandas/tests/frame/indexing/test_insert.py
21 issues
Line: 7
Column: 1
__setitem__.
"""
import numpy as np
import pytest
from pandas.errors import PerformanceWarning
from pandas import (
DataFrame,
Reported by Pylint.
Line: 18
Column: 1
import pandas._testing as tm
class TestDataFrameInsert:
def test_insert(self):
df = DataFrame(
np.random.randn(5, 3), index=np.arange(5), columns=["c", "b", "a"]
)
Reported by Pylint.
Line: 19
Column: 5
class TestDataFrameInsert:
def test_insert(self):
df = DataFrame(
np.random.randn(5, 3), index=np.arange(5), columns=["c", "b", "a"]
)
df.insert(0, "foo", df["a"])
Reported by Pylint.
Line: 19
Column: 5
class TestDataFrameInsert:
def test_insert(self):
df = DataFrame(
np.random.randn(5, 3), index=np.arange(5), columns=["c", "b", "a"]
)
df.insert(0, "foo", df["a"])
Reported by Pylint.
Line: 20
Column: 9
class TestDataFrameInsert:
def test_insert(self):
df = DataFrame(
np.random.randn(5, 3), index=np.arange(5), columns=["c", "b", "a"]
)
df.insert(0, "foo", df["a"])
tm.assert_index_equal(df.columns, Index(["foo", "c", "b", "a"]))
Reported by Pylint.
Line: 42
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
df.columns.name = "some_name"
# preserve columns name field
df.insert(0, "baz", df["c"])
assert df.columns.name == "some_name"
def test_insert_column_bug_4032(self):
# GH#4032, inserting a column and renaming causing errors
df = DataFrame({"b": [1.1, 2.2]})
Reported by Bandit.
Line: 44
Column: 5
df.insert(0, "baz", df["c"])
assert df.columns.name == "some_name"
def test_insert_column_bug_4032(self):
# GH#4032, inserting a column and renaming causing errors
df = DataFrame({"b": [1.1, 2.2]})
df = df.rename(columns={})
Reported by Pylint.
Line: 44
Column: 5
df.insert(0, "baz", df["c"])
assert df.columns.name == "some_name"
def test_insert_column_bug_4032(self):
# GH#4032, inserting a column and renaming causing errors
df = DataFrame({"b": [1.1, 2.2]})
df = df.rename(columns={})
Reported by Pylint.
Line: 47
Column: 9
def test_insert_column_bug_4032(self):
# GH#4032, inserting a column and renaming causing errors
df = DataFrame({"b": [1.1, 2.2]})
df = df.rename(columns={})
df.insert(0, "a", [1, 2])
result = df.rename(columns={})
Reported by Pylint.
Line: 49
Column: 9
# GH#4032, inserting a column and renaming causing errors
df = DataFrame({"b": [1.1, 2.2]})
df = df.rename(columns={})
df.insert(0, "a", [1, 2])
result = df.rename(columns={})
str(result)
expected = DataFrame([[1, 1.1], [2, 2.2]], columns=["a", "b"])
Reported by Pylint.
pandas/tests/io/parser/common/test_chunksize.py
21 issues
Line: 8
Column: 1
from io import StringIO
import numpy as np
import pytest
from pandas.errors import DtypeWarning
from pandas import (
DataFrame,
Reported by Pylint.
Line: 20
Column: 49
@pytest.mark.parametrize("index_col", [0, "index"])
def test_read_chunksize_with_index(all_parsers, index_col):
parser = all_parsers
data = """index,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
Reported by Pylint.
Line: 20
Column: 1
@pytest.mark.parametrize("index_col", [0, "index"])
def test_read_chunksize_with_index(all_parsers, index_col):
parser = all_parsers
data = """index,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
Reported by Pylint.
Line: 52
Column: 1
@pytest.mark.parametrize("chunksize", [1.3, "foo", 0])
def test_read_chunksize_bad(all_parsers, chunksize):
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: 70
Column: 1
@pytest.mark.parametrize("chunksize", [2, 8])
def test_read_chunksize_and_nrows(all_parsers, chunksize):
# see gh-15755
data = """index,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
Reported by Pylint.
Line: 88
Column: 1
tm.assert_frame_equal(concat(reader), expected)
def test_read_chunksize_and_nrows_changing_size(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: 109
Column: 1
reader.get_chunk(size=3)
def test_get_chunk_passed_chunksize(all_parsers):
parser = all_parsers
data = """A,B,C
1,2,3
4,5,6
7,8,9
Reported by Pylint.
Line: 125
Column: 1
@pytest.mark.parametrize("kwargs", [{}, {"index_col": 0}])
def test_read_chunksize_compat(all_parsers, kwargs):
# see gh-12185
data = """index,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
Reported by Pylint.
Line: 141
Column: 1
tm.assert_frame_equal(concat(reader), result)
def test_read_chunksize_jagged_names(all_parsers):
# see gh-23509
parser = all_parsers
data = "\n".join(["0"] * 7 + [",".join(["0"] * 10)])
expected = DataFrame([[0] + [np.nan] * 9] * 7 + [[0] * 10])
Reported by Pylint.
Line: 152
Column: 1
tm.assert_frame_equal(result, expected)
def test_chunk_begins_with_newline_whitespace(all_parsers):
# see gh-10022
parser = all_parsers
data = "\n hello\nworld\n"
result = parser.read_csv(StringIO(data), header=None)
Reported by Pylint.
pandas/tests/series/methods/test_copy.py
21 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Series,
Timestamp,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Series,
Timestamp,
)
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestCopy:
@pytest.mark.parametrize("deep", [None, False, True])
def test_copy(self, deep):
ser = Series(np.arange(10), dtype="float64")
Reported by Pylint.
Line: 13
Column: 5
class TestCopy:
@pytest.mark.parametrize("deep", [None, False, True])
def test_copy(self, deep):
ser = Series(np.arange(10), dtype="float64")
# default deep is True
if deep is None:
Reported by Pylint.
Line: 13
Column: 5
class TestCopy:
@pytest.mark.parametrize("deep", [None, False, True])
def test_copy(self, deep):
ser = Series(np.arange(10), dtype="float64")
# default deep is True
if deep is None:
Reported by Pylint.
Line: 27
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if deep is None or deep is True:
# Did not modify original Series
assert np.isnan(ser2[0])
assert not np.isnan(ser[0])
else:
# we DID modify the original Series
assert np.isnan(ser2[0])
assert np.isnan(ser[0])
Reported by Bandit.
Line: 28
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if deep is None or deep is True:
# Did not modify original Series
assert np.isnan(ser2[0])
assert not np.isnan(ser[0])
else:
# we DID modify the original Series
assert np.isnan(ser2[0])
assert np.isnan(ser[0])
Reported by Bandit.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert not np.isnan(ser[0])
else:
# we DID modify the original Series
assert np.isnan(ser2[0])
assert np.isnan(ser[0])
@pytest.mark.parametrize("deep", [None, False, True])
def test_copy_tzaware(self, deep):
# GH#11794
Reported by Bandit.
Line: 32
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
else:
# we DID modify the original Series
assert np.isnan(ser2[0])
assert np.isnan(ser[0])
@pytest.mark.parametrize("deep", [None, False, True])
def test_copy_tzaware(self, deep):
# GH#11794
# copy of tz-aware
Reported by Bandit.
Line: 35
Column: 5
assert np.isnan(ser[0])
@pytest.mark.parametrize("deep", [None, False, True])
def test_copy_tzaware(self, deep):
# GH#11794
# copy of tz-aware
expected = Series([Timestamp("2012/01/01", tz="UTC")])
expected2 = Series([Timestamp("1999/01/01", tz="UTC")])
Reported by Pylint.
pandas/tests/indexes/multi/test_copy.py
21 issues
Line: 6
Column: 1
deepcopy,
)
import pytest
from pandas import MultiIndex
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 30
import pandas._testing as tm
def assert_multiindex_copied(copy, original):
# Levels should be (at least, shallow copied)
tm.assert_copy(copy.levels, original.levels)
tm.assert_almost_equal(copy.codes, original.codes)
# Labels doesn't matter which way copied
Reported by Pylint.
Line: 36
Column: 14
def test_shallow_copy(idx):
i_copy = idx._view()
assert_multiindex_copied(i_copy, idx)
def test_view(idx):
Reported by Pylint.
Line: 1
Column: 1
from copy import (
copy,
deepcopy,
)
import pytest
from pandas import MultiIndex
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 1
import pandas._testing as tm
def assert_multiindex_copied(copy, original):
# Levels should be (at least, shallow copied)
tm.assert_copy(copy.levels, original.levels)
tm.assert_almost_equal(copy.codes, original.codes)
# Labels doesn't matter which way copied
Reported by Pylint.
Line: 19
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# Labels doesn't matter which way copied
tm.assert_almost_equal(copy.codes, original.codes)
assert copy.codes is not original.codes
# Names doesn't matter which way copied
assert copy.names == original.names
assert copy.names is not original.names
Reported by Bandit.
Line: 22
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert copy.codes is not original.codes
# Names doesn't matter which way copied
assert copy.names == original.names
assert copy.names is not original.names
# Sort order should be copied
assert copy.sortorder == original.sortorder
Reported by Bandit.
Line: 23
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# Names doesn't matter which way copied
assert copy.names == original.names
assert copy.names is not original.names
# Sort order should be copied
assert copy.sortorder == original.sortorder
Reported by Bandit.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert copy.names is not original.names
# Sort order should be copied
assert copy.sortorder == original.sortorder
def test_copy(idx):
i_copy = idx.copy()
Reported by Bandit.
Line: 29
Column: 1
assert copy.sortorder == original.sortorder
def test_copy(idx):
i_copy = idx.copy()
assert_multiindex_copied(i_copy, idx)
Reported by Pylint.
pandas/tests/io/parser/test_python_parser_only.py
21 issues
Line: 14
Column: 1
StringIO,
)
import pytest
from pandas.errors import ParserError
from pandas import (
DataFrame,
Reported by Pylint.
Line: 26
Column: 1
import pandas._testing as tm
def test_default_separator(python_parser_only):
# see gh-17333
#
# csv.Sniffer in Python treats "o" as separator.
data = "aob\n1o2\n3o4"
parser = python_parser_only
Reported by Pylint.
Line: 39
Column: 1
@pytest.mark.parametrize("skipfooter", ["foo", 1.5, True])
def test_invalid_skipfooter_non_int(python_parser_only, skipfooter):
# see gh-15925 (comment)
data = "a\n1\n2"
parser = python_parser_only
msg = "skipfooter must be an integer"
Reported by Pylint.
Line: 49
Column: 1
parser.read_csv(StringIO(data), skipfooter=skipfooter)
def test_invalid_skipfooter_negative(python_parser_only):
# see gh-15925 (comment)
data = "a\n1\n2"
parser = python_parser_only
msg = "skipfooter cannot be negative"
Reported by Pylint.
Line: 60
Column: 1
@pytest.mark.parametrize("kwargs", [{"sep": None}, {"delimiter": "|"}])
def test_sniff_delimiter(python_parser_only, kwargs):
data = """index|A|B|C
foo|1|2|3
bar|4|5|6
baz|7|8|9
"""
Reported by Pylint.
Line: 76
Column: 1
tm.assert_frame_equal(result, expected)
def test_sniff_delimiter_comment(python_parser_only):
data = """# comment line
index|A|B|C
# comment line
foo|1|2|3 # ignore | this
bar|4|5|6
Reported by Pylint.
Line: 95
Column: 1
@pytest.mark.parametrize("encoding", [None, "utf-8"])
def test_sniff_delimiter_encoding(python_parser_only, encoding):
parser = python_parser_only
data = """ignore this
ignore this too
index|A|B|C
foo|1|2|3
Reported by Pylint.
Line: 106
Column: 9
"""
if encoding is not None:
from io import TextIOWrapper
data = data.encode(encoding)
data = BytesIO(data)
data = TextIOWrapper(data, encoding=encoding)
else:
Reported by Pylint.
Line: 123
Column: 1
tm.assert_frame_equal(result, expected)
def test_single_line(python_parser_only):
# see gh-6607: sniff separator
parser = python_parser_only
result = parser.read_csv(StringIO("1,2"), names=["a", "b"], header=None, sep=None)
expected = DataFrame({"a": [1], "b": [2]})
Reported by Pylint.
Line: 133
Column: 1
@pytest.mark.parametrize("kwargs", [{"skipfooter": 2}, {"nrows": 3}])
def test_skipfooter(python_parser_only, kwargs):
# see gh-6607
data = """A,B,C
1,2,3
4,5,6
7,8,9
Reported by Pylint.
pandas/tests/tslibs/test_to_offset.py
21 issues
Line: 3
Column: 1
import re
import pytest
from pandas._libs.tslibs import (
Timedelta,
offsets,
to_offset,
)
Reported by Pylint.
Line: 5
Column: 1
import pytest
from pandas._libs.tslibs import (
Timedelta,
offsets,
to_offset,
)
Reported by Pylint.
Line: 1
Column: 1
import re
import pytest
from pandas._libs.tslibs import (
Timedelta,
offsets,
to_offset,
)
Reported by Pylint.
Line: 33
Column: 1
("2SM-16", offsets.SemiMonthEnd(2, day_of_month=16)),
("2SMS-14", offsets.SemiMonthBegin(2, day_of_month=14)),
("2SMS-15", offsets.SemiMonthBegin(2)),
],
)
def test_to_offset(freq_input, expected):
result = to_offset(freq_input)
assert result == expected
Reported by Pylint.
Line: 37
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_to_offset(freq_input, expected):
result = to_offset(freq_input)
assert result == expected
@pytest.mark.parametrize(
"freqstr,expected", [("-1S", -1), ("-2SM", -2), ("-1SMS", -1), ("-5min10s", -310)]
)
Reported by Bandit.
Line: 42
Column: 1
@pytest.mark.parametrize(
"freqstr,expected", [("-1S", -1), ("-2SM", -2), ("-1SMS", -1), ("-5min10s", -310)]
)
def test_to_offset_negative(freqstr, expected):
result = to_offset(freqstr)
assert result.n == expected
Reported by Pylint.
Line: 45
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_to_offset_negative(freqstr, expected):
result = to_offset(freqstr)
assert result.n == expected
@pytest.mark.parametrize(
"freqstr",
[
Reported by Bandit.
Line: 82
Column: 1
"SMS-BYR",
"BSMS",
"SMS--2",
],
)
def test_to_offset_invalid(freqstr):
# see gh-13930
# We escape string because some of our
Reported by Pylint.
Line: 94
Column: 1
to_offset(freqstr)
def test_to_offset_no_evaluate():
msg = str(("", ""))
with pytest.raises(TypeError, match=msg):
to_offset(("", ""))
Reported by Pylint.
Line: 100
Column: 1
to_offset(("", ""))
def test_to_offset_tuple_unsupported():
with pytest.raises(TypeError, match="pass as a string instead"):
to_offset((5, "T"))
@pytest.mark.parametrize(
Reported by Pylint.
pandas/tests/indexes/period/test_join.py
21 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs import IncompatibleFrequency
from pandas import (
Index,
PeriodIndex,
period_range,
Reported by Pylint.
Line: 18
Column: 18
def test_join_outer_indexer(self):
pi = period_range("1/1/2000", "1/20/2000", freq="D")
result = pi._outer_indexer(pi)
tm.assert_extension_array_equal(result[0], pi._values)
tm.assert_numpy_array_equal(result[1], np.arange(len(pi), dtype=np.intp))
tm.assert_numpy_array_equal(result[2], np.arange(len(pi), dtype=np.intp))
def test_joins(self, join_type):
Reported by Pylint.
Line: 19
Column: 52
pi = period_range("1/1/2000", "1/20/2000", freq="D")
result = pi._outer_indexer(pi)
tm.assert_extension_array_equal(result[0], pi._values)
tm.assert_numpy_array_equal(result[1], np.arange(len(pi), dtype=np.intp))
tm.assert_numpy_array_equal(result[2], np.arange(len(pi), dtype=np.intp))
def test_joins(self, join_type):
index = period_range("1/1/2000", "1/20/2000", freq="D")
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs import IncompatibleFrequency
from pandas import (
Index,
PeriodIndex,
period_range,
Reported by Pylint.
Line: 14
Column: 1
import pandas._testing as tm
class TestJoin:
def test_join_outer_indexer(self):
pi = period_range("1/1/2000", "1/20/2000", freq="D")
result = pi._outer_indexer(pi)
tm.assert_extension_array_equal(result[0], pi._values)
Reported by Pylint.
Line: 15
Column: 5
class TestJoin:
def test_join_outer_indexer(self):
pi = period_range("1/1/2000", "1/20/2000", freq="D")
result = pi._outer_indexer(pi)
tm.assert_extension_array_equal(result[0], pi._values)
tm.assert_numpy_array_equal(result[1], np.arange(len(pi), dtype=np.intp))
Reported by Pylint.
Line: 15
Column: 5
class TestJoin:
def test_join_outer_indexer(self):
pi = period_range("1/1/2000", "1/20/2000", freq="D")
result = pi._outer_indexer(pi)
tm.assert_extension_array_equal(result[0], pi._values)
tm.assert_numpy_array_equal(result[1], np.arange(len(pi), dtype=np.intp))
Reported by Pylint.
Line: 16
Column: 9
class TestJoin:
def test_join_outer_indexer(self):
pi = period_range("1/1/2000", "1/20/2000", freq="D")
result = pi._outer_indexer(pi)
tm.assert_extension_array_equal(result[0], pi._values)
tm.assert_numpy_array_equal(result[1], np.arange(len(pi), dtype=np.intp))
tm.assert_numpy_array_equal(result[2], np.arange(len(pi), dtype=np.intp))
Reported by Pylint.
Line: 23
Column: 5
tm.assert_numpy_array_equal(result[1], np.arange(len(pi), dtype=np.intp))
tm.assert_numpy_array_equal(result[2], np.arange(len(pi), dtype=np.intp))
def test_joins(self, join_type):
index = period_range("1/1/2000", "1/20/2000", freq="D")
joined = index.join(index[:-5], how=join_type)
assert isinstance(joined, PeriodIndex)
Reported by Pylint.
Line: 23
Column: 5
tm.assert_numpy_array_equal(result[1], np.arange(len(pi), dtype=np.intp))
tm.assert_numpy_array_equal(result[2], np.arange(len(pi), dtype=np.intp))
def test_joins(self, join_type):
index = period_range("1/1/2000", "1/20/2000", freq="D")
joined = index.join(index[:-5], how=join_type)
assert isinstance(joined, PeriodIndex)
Reported by Pylint.
pandas/tests/series/indexing/test_delitem.py
21 issues
Line: 1
Column: 1
import pytest
from pandas import (
Index,
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 67
Column: 14
tm.assert_series_equal(ser, expected)
# PeriodDtype
pi = dti.tz_localize(None).to_period("D")
ser = Series(pi)
expected = ser[:2]
del ser[2]
assert ser.dtype == pi.dtype
Reported by Pylint.
Line: 67
Column: 14
tm.assert_series_equal(ser, expected)
# PeriodDtype
pi = dti.tz_localize(None).to_period("D")
ser = Series(pi)
expected = ser[:2]
del ser[2]
assert ser.dtype == pi.dtype
Reported by Pylint.
Line: 63
Column: 16
expected = ser[[0, 2]]
del ser[1]
assert ser.dtype == dti.dtype
tm.assert_series_equal(ser, expected)
# PeriodDtype
pi = dti.tz_localize(None).to_period("D")
ser = Series(pi)
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import (
Index,
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestSeriesDelItem:
def test_delitem(self):
# GH#5542
# should delete the item inplace
s = Series(range(5))
del s[0]
Reported by Pylint.
Line: 12
Column: 5
class TestSeriesDelItem:
def test_delitem(self):
# GH#5542
# should delete the item inplace
s = Series(range(5))
del s[0]
Reported by Pylint.
Line: 12
Column: 5
class TestSeriesDelItem:
def test_delitem(self):
# GH#5542
# should delete the item inplace
s = Series(range(5))
del s[0]
Reported by Pylint.
Line: 15
Column: 9
def test_delitem(self):
# GH#5542
# should delete the item inplace
s = Series(range(5))
del s[0]
expected = Series(range(1, 5), index=range(1, 5))
tm.assert_series_equal(s, expected)
Reported by Pylint.
Line: 26
Column: 9
tm.assert_series_equal(s, expected)
# only 1 left, del, add, del
s = Series(1)
del s[0]
tm.assert_series_equal(s, Series(dtype="int64", index=Index([], dtype="int64")))
s[0] = 1
tm.assert_series_equal(s, Series(1))
del s[0]
Reported by Pylint.
pandas/tests/io/pytables/test_compat.py
21 issues
Line: 1
Column: 1
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.tests.io.pytables.common import ensure_clean_path
tables = pytest.importorskip("tables")
Reported by Pylint.
Line: 52
Column: 34
Was introduced for regression-testing issue 11188.
"""
def test_read_complete(self, pytables_hdf5_file):
path, objname, df = pytables_hdf5_file
result = pd.read_hdf(path, key=objname)
expected = df
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 58
Column: 36
expected = df
tm.assert_frame_equal(result, expected)
def test_read_with_start(self, pytables_hdf5_file):
path, objname, df = pytables_hdf5_file
# This is a regression test for pandas-dev/pandas/issues/11188
result = pd.read_hdf(path, key=objname, start=1)
expected = df[1:].reset_index(drop=True)
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 65
Column: 35
expected = df[1:].reset_index(drop=True)
tm.assert_frame_equal(result, expected)
def test_read_with_stop(self, pytables_hdf5_file):
path, objname, df = pytables_hdf5_file
# This is a regression test for pandas-dev/pandas/issues/11188
result = pd.read_hdf(path, key=objname, stop=1)
expected = df[:1].reset_index(drop=True)
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 72
Column: 40
expected = df[:1].reset_index(drop=True)
tm.assert_frame_equal(result, expected)
def test_read_with_startstop(self, pytables_hdf5_file):
path, objname, df = pytables_hdf5_file
# This is a regression test for pandas-dev/pandas/issues/11188
result = pd.read_hdf(path, key=objname, start=1, stop=2)
expected = df[1:2].reset_index(drop=True)
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 1
Column: 1
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.tests.io.pytables.common import ensure_clean_path
tables = pytest.importorskip("tables")
Reported by Pylint.
Line: 21
Column: 5
"c2": tables.Int64Col(pos=2),
}
t0 = 1_561_105_000.0
testsamples = [
{"c0": t0, "c1": "aaaaa", "c2": 1},
{"c0": t0 + 1, "c1": "bbbbb", "c2": 2},
{"c0": t0 + 2, "c1": "ccccc", "c2": 10 ** 5},
Reported by Pylint.
Line: 34
Column: 50
with ensure_clean_path("written_with_pytables.h5") as path:
# The `ensure_clean_path` context mgr removes the temp file upon exit.
with tables.open_file(path, mode="w") as f:
t = f.create_table("/", name=objname, description=table_schema)
for sample in testsamples:
for key, value in sample.items():
t.row[key] = value
t.row.append()
Reported by Pylint.
Line: 35
Column: 13
with ensure_clean_path("written_with_pytables.h5") as path:
# The `ensure_clean_path` context mgr removes the temp file upon exit.
with tables.open_file(path, mode="w") as f:
t = f.create_table("/", name=objname, description=table_schema)
for sample in testsamples:
for key, value in sample.items():
t.row[key] = value
t.row.append()
Reported by Pylint.
Line: 52
Column: 5
Was introduced for regression-testing issue 11188.
"""
def test_read_complete(self, pytables_hdf5_file):
path, objname, df = pytables_hdf5_file
result = pd.read_hdf(path, key=objname)
expected = df
tm.assert_frame_equal(result, expected)
Reported by Pylint.