The following issues were found
pandas/tests/indexes/multi/test_partial_indexing.py
26 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
IndexSlice,
MultiIndex,
date_range,
)
Reported by Pylint.
Line: 38
Column: 47
return frame
def test_partial_string_matching_single_index(df):
# partial string matching on a single index
for df_swap in [df.swaplevel(), df.swaplevel(0), df.swaplevel(0, 1)]:
df_swap = df_swap.sort_index()
just_a = df_swap.loc["a"]
result = just_a.loc["2016-01-01"]
Reported by Pylint.
Line: 49
Column: 47
tm.assert_frame_equal(result, expected)
def test_get_loc_partial_timestamp_multiindex(df):
mi = df.index
key = ("2016-01-01", "a")
loc = mi.get_loc(key)
expected = np.zeros(len(mi), dtype=bool)
Reported by Pylint.
Line: 85
Column: 46
tm.assert_numpy_array_equal(loc5, expected5)
def test_partial_string_timestamp_multiindex(df):
# GH10331
df_swap = df.swaplevel(0, 1).sort_index()
SLC = IndexSlice
# indexing with IndexSlice
Reported by Pylint.
Line: 132
Column: 9
# Slicing date on first level should break (of course) bc the DTI is the
# second level on df_swap
with pytest.raises(KeyError, match="'2016-01-01'"):
df_swap.loc["2016-01-01"]
def test_partial_string_timestamp_multiindex_str_key_raises(df):
# Even though this syntax works on a single index, this is somewhat
# ambiguous and we don't want to extend this behavior forward to work
Reported by Pylint.
Line: 135
Column: 61
df_swap.loc["2016-01-01"]
def test_partial_string_timestamp_multiindex_str_key_raises(df):
# Even though this syntax works on a single index, this is somewhat
# ambiguous and we don't want to extend this behavior forward to work
# in multi-indexes. This would amount to selecting a scalar from a
# column.
with pytest.raises(KeyError, match="'2016-01-01'"):
Reported by Pylint.
Line: 141
Column: 9
# in multi-indexes. This would amount to selecting a scalar from a
# column.
with pytest.raises(KeyError, match="'2016-01-01'"):
df["2016-01-01"]
def test_partial_string_timestamp_multiindex_daily_resolution(df):
# GH12685 (partial string with daily resolution or below)
result = df.loc[IndexSlice["2013-03":"2013-03", :], :]
Reported by Pylint.
Line: 144
Column: 63
df["2016-01-01"]
def test_partial_string_timestamp_multiindex_daily_resolution(df):
# GH12685 (partial string with daily resolution or below)
result = df.loc[IndexSlice["2013-03":"2013-03", :], :]
expected = df.iloc[118:180]
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
IndexSlice,
MultiIndex,
date_range,
)
Reported by Pylint.
Line: 14
Column: 1
@pytest.fixture
def df():
# c1
# 2016-01-01 00:00:00 a 0
# b 1
# c 2
# 2016-01-01 12:00:00 a 3
Reported by Pylint.
pandas/tests/reshape/merge/test_merge_ordered.py
26 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
merge_ordered,
)
import pandas._testing as tm
Reported by Pylint.
Line: 13
Column: 28
class TestMergeOrdered:
def setup_method(self, method):
self.left = DataFrame({"key": ["a", "c", "e"], "lvalue": [1, 2.0, 3]})
self.right = DataFrame({"key": ["b", "c", "d", "f"], "rvalue": [1, 2, 3.0, 4]})
def test_basic(self):
Reported by Pylint.
Line: 14
Column: 9
class TestMergeOrdered:
def setup_method(self, method):
self.left = DataFrame({"key": ["a", "c", "e"], "lvalue": [1, 2.0, 3]})
self.right = DataFrame({"key": ["b", "c", "d", "f"], "rvalue": [1, 2, 3.0, 4]})
def test_basic(self):
result = merge_ordered(self.left, self.right, on="key")
Reported by Pylint.
Line: 16
Column: 9
def setup_method(self, method):
self.left = DataFrame({"key": ["a", "c", "e"], "lvalue": [1, 2.0, 3]})
self.right = DataFrame({"key": ["b", "c", "d", "f"], "rvalue": [1, 2, 3.0, 4]})
def test_basic(self):
result = merge_ordered(self.left, self.right, on="key")
expected = DataFrame(
{
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
merge_ordered,
)
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 1
import pandas._testing as tm
class TestMergeOrdered:
def setup_method(self, method):
self.left = DataFrame({"key": ["a", "c", "e"], "lvalue": [1, 2.0, 3]})
self.right = DataFrame({"key": ["b", "c", "d", "f"], "rvalue": [1, 2, 3.0, 4]})
Reported by Pylint.
Line: 13
Column: 5
class TestMergeOrdered:
def setup_method(self, method):
self.left = DataFrame({"key": ["a", "c", "e"], "lvalue": [1, 2.0, 3]})
self.right = DataFrame({"key": ["b", "c", "d", "f"], "rvalue": [1, 2, 3.0, 4]})
def test_basic(self):
Reported by Pylint.
Line: 18
Column: 5
self.right = DataFrame({"key": ["b", "c", "d", "f"], "rvalue": [1, 2, 3.0, 4]})
def test_basic(self):
result = merge_ordered(self.left, self.right, on="key")
expected = DataFrame(
{
"key": ["a", "b", "c", "d", "e", "f"],
"lvalue": [1, np.nan, 2, np.nan, 3, np.nan],
Reported by Pylint.
Line: 30
Column: 5
tm.assert_frame_equal(result, expected)
def test_ffill(self):
result = merge_ordered(self.left, self.right, on="key", fill_method="ffill")
expected = DataFrame(
{
"key": ["a", "b", "c", "d", "e", "f"],
"lvalue": [1.0, 1, 2, 2, 3, 3.0],
Reported by Pylint.
Line: 41
Column: 5
)
tm.assert_frame_equal(result, expected)
def test_multigroup(self):
left = pd.concat([self.left, self.left], ignore_index=True)
left["group"] = ["a"] * 3 + ["b"] * 3
result = merge_ordered(
Reported by Pylint.
pandas/tests/io/test_compression.py
26 issues
Line: 9
Column: 1
import textwrap
import time
import pytest
import pandas as pd
import pandas._testing as tm
import pandas.io.common as icom
Reported by Pylint.
Line: 74
Column: 5
write_method, write_kwargs, read_method, compression_only
):
# GH22004
input = pd.DataFrame([[1.0, 0, -4], [3.4, 5, 2]], columns=["X", "Y", "Z"])
extension = icom._compression_to_extension[compression_only]
with tm.ensure_clean("compressed" + extension) as path:
getattr(input, write_method)(path, **write_kwargs)
output = read_method(path, compression=compression_only)
tm.assert_frame_equal(output, input)
Reported by Pylint.
Line: 75
Column: 17
):
# GH22004
input = pd.DataFrame([[1.0, 0, -4], [3.4, 5, 2]], columns=["X", "Y", "Z"])
extension = icom._compression_to_extension[compression_only]
with tm.ensure_clean("compressed" + extension) as path:
getattr(input, write_method)(path, **write_kwargs)
output = read_method(path, compression=compression_only)
tm.assert_frame_equal(output, input)
Reported by Pylint.
Line: 94
Column: 5
write_method, write_kwargs, read_method, read_kwargs, compression_only
):
# GH22004
input = pd.Series([0, 5, -2, 10], name="X")
extension = icom._compression_to_extension[compression_only]
with tm.ensure_clean("compressed" + extension) as path:
getattr(input, write_method)(path, **write_kwargs)
output = read_method(path, compression=compression_only, **read_kwargs)
tm.assert_series_equal(output, input, check_names=False)
Reported by Pylint.
Line: 95
Column: 17
):
# GH22004
input = pd.Series([0, 5, -2, 10], name="X")
extension = icom._compression_to_extension[compression_only]
with tm.ensure_clean("compressed" + extension) as path:
getattr(input, write_method)(path, **write_kwargs)
output = read_method(path, compression=compression_only, **read_kwargs)
tm.assert_series_equal(output, input, check_names=False)
Reported by Pylint.
Line: 1
Column: 1
import io
import os
from pathlib import Path
import subprocess
import sys
import textwrap
import time
import pytest
Reported by Pylint.
Line: 4
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import io
import os
from pathlib import Path
import subprocess
import sys
import textwrap
import time
import pytest
Reported by Bandit.
Line: 26
Column: 1
),
pd.Series(100 * [0.123456, 0.234567, 0.567567], name="X"),
],
)
@pytest.mark.parametrize("method", ["to_pickle", "to_json", "to_csv"])
def test_compression_size(obj, method, compression_only):
with tm.ensure_clean() as path:
getattr(obj, method)(path, compression=compression_only)
compressed_size = os.path.getsize(path)
Reported by Pylint.
Line: 34
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
compressed_size = os.path.getsize(path)
getattr(obj, method)(path, compression=None)
uncompressed_size = os.path.getsize(path)
assert uncompressed_size > compressed_size
@pytest.mark.parametrize(
"obj",
[
Reported by Bandit.
Line: 46
Column: 1
),
pd.Series(100 * [0.123456, 0.234567, 0.567567], name="X"),
],
)
@pytest.mark.parametrize("method", ["to_csv", "to_json"])
def test_compression_size_fh(obj, method, compression_only):
with tm.ensure_clean() as path:
with icom.get_handle(path, "w", compression=compression_only) as handles:
getattr(obj, method)(handles.handle)
Reported by Pylint.
pandas/io/excel/_odswriter.py
26 issues
Line: 10
Column: 1
DefaultDict,
)
import pandas._libs.json as json
from pandas._typing import StorageOptions
from pandas.io.excel._base import ExcelWriter
from pandas.io.excel._util import validate_freeze_panes
from pandas.io.formats.excel import ExcelCell
Reported by Pylint.
Line: 10
Column: 1
DefaultDict,
)
import pandas._libs.json as json
from pandas._typing import StorageOptions
from pandas.io.excel._base import ExcelWriter
from pandas.io.excel._util import validate_freeze_panes
from pandas.io.formats.excel import ExcelCell
Reported by Pylint.
Line: 34
Column: 9
engine_kwargs: dict[str, Any] | None = None,
**kwargs,
):
from odf.opendocument import OpenDocumentSpreadsheet
if mode == "a":
raise ValueError("Append mode is not supported with odf!")
super().__init__(
Reported by Pylint.
Line: 69
Column: 9
"""
Write the frame cells using odf
"""
from odf.table import (
Table,
TableCell,
TableRow,
)
from odf.text import P
Reported by Pylint.
Line: 74
Column: 9
TableCell,
TableRow,
)
from odf.text import P
sheet_name = self._get_sheet_name(sheet_name)
assert sheet_name is not None
if sheet_name in self.sheets:
Reported by Pylint.
Line: 151
Column: 9
pvalue, cell : Tuple[str, TableCell]
Display value, Cell value
"""
from odf.table import TableCell
attributes = self._make_table_cell_attributes(cell)
val, fmt = self._value_with_fmt(cell.val)
pvalue = value = val
if isinstance(val, bool):
Reported by Pylint.
Line: 202
Column: 9
style_key : str
Unique style key for later reference in sheet
"""
from odf.style import (
ParagraphProperties,
Style,
TableCellProperties,
TextProperties,
)
Reported by Pylint.
Line: 254
Column: 9
freeze_panes : tuple of (int, int)
Freeze pane location x and y
"""
from odf.config import (
ConfigItem,
ConfigItemMapEntry,
ConfigItemMapIndexed,
ConfigItemMapNamed,
ConfigItemSet,
Reported by Pylint.
Line: 154
Column: 14
from odf.table import TableCell
attributes = self._make_table_cell_attributes(cell)
val, fmt = self._value_with_fmt(cell.val)
pvalue = value = val
if isinstance(val, bool):
value = str(val).lower()
pvalue = str(val).upper()
if isinstance(val, datetime.datetime):
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from collections import defaultdict
import datetime
from typing import (
Any,
DefaultDict,
)
Reported by Pylint.
pandas/tests/indexes/categorical/test_fillna.py
26 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import CategoricalIndex
import pandas._testing as tm
class TestFillNA:
def test_fillna_categorical(self):
Reported by Pylint.
Line: 16
Column: 15
exp = CategoricalIndex([1.0, 1.0, 3.0, 1.0], name="x")
tm.assert_index_equal(idx.fillna(1.0), exp)
cat = idx._data
# fill by value not in categories raises TypeError on EA, casts on CI
msg = "Cannot setitem on a Categorical with a new category"
with pytest.raises(TypeError, match=msg):
cat.fillna(2.0)
Reported by Pylint.
Line: 30
Column: 15
def test_fillna_copies_with_no_nas(self):
# Nothing to fill, should still get a copy
ci = CategoricalIndex([0, 1, 1])
cat = ci._data
result = ci.fillna(0)
assert result._values._ndarray is not cat._ndarray
assert result._values._ndarray.base is None
# Same check directly on the Categorical object
Reported by Pylint.
Line: 32
Column: 47
ci = CategoricalIndex([0, 1, 1])
cat = ci._data
result = ci.fillna(0)
assert result._values._ndarray is not cat._ndarray
assert result._values._ndarray.base is None
# Same check directly on the Categorical object
result = cat.fillna(0)
assert result._ndarray is not cat._ndarray
Reported by Pylint.
Line: 32
Column: 16
ci = CategoricalIndex([0, 1, 1])
cat = ci._data
result = ci.fillna(0)
assert result._values._ndarray is not cat._ndarray
assert result._values._ndarray.base is None
# Same check directly on the Categorical object
result = cat.fillna(0)
assert result._ndarray is not cat._ndarray
Reported by Pylint.
Line: 32
Column: 16
ci = CategoricalIndex([0, 1, 1])
cat = ci._data
result = ci.fillna(0)
assert result._values._ndarray is not cat._ndarray
assert result._values._ndarray.base is None
# Same check directly on the Categorical object
result = cat.fillna(0)
assert result._ndarray is not cat._ndarray
Reported by Pylint.
Line: 33
Column: 16
cat = ci._data
result = ci.fillna(0)
assert result._values._ndarray is not cat._ndarray
assert result._values._ndarray.base is None
# Same check directly on the Categorical object
result = cat.fillna(0)
assert result._ndarray is not cat._ndarray
assert result._ndarray.base is None
Reported by Pylint.
Line: 33
Column: 16
cat = ci._data
result = ci.fillna(0)
assert result._values._ndarray is not cat._ndarray
assert result._values._ndarray.base is None
# Same check directly on the Categorical object
result = cat.fillna(0)
assert result._ndarray is not cat._ndarray
assert result._ndarray.base is None
Reported by Pylint.
Line: 37
Column: 39
# Same check directly on the Categorical object
result = cat.fillna(0)
assert result._ndarray is not cat._ndarray
assert result._ndarray.base is None
def test_fillna_validates_with_no_nas(self):
# We validate the fill value even if fillna is a no-op
ci = CategoricalIndex([2, 3, 3])
Reported by Pylint.
Line: 37
Column: 16
# Same check directly on the Categorical object
result = cat.fillna(0)
assert result._ndarray is not cat._ndarray
assert result._ndarray.base is None
def test_fillna_validates_with_no_nas(self):
# We validate the fill value even if fillna is a no-op
ci = CategoricalIndex([2, 3, 3])
Reported by Pylint.
pandas/__init__.py
26 issues
Line: 119
Column: 1
from pandas.tseries.api import infer_freq
from pandas.tseries import offsets
from pandas.core.computation.api import eval
from pandas.core.reshape.api import (
concat,
lreshape,
melt,
Reported by Pylint.
Line: 12
Column: 5
for dependency in hard_dependencies:
try:
__import__(dependency)
except ImportError as e:
missing_dependencies.append(f"{dependency}: {e}")
if missing_dependencies:
raise ImportError(
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
Reported by Pylint.
Line: 22
Column: 1
del hard_dependencies, dependency, missing_dependencies
# numpy compat
from pandas.compat import is_numpy_dev as _is_numpy_dev
try:
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
except ImportError as e: # pragma: no cover
module = e.name
Reported by Pylint.
Line: 26
Column: 1
try:
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
except ImportError as e: # pragma: no cover
module = e.name
raise ImportError(
f"C extension: {module} not built. If you want to import "
"pandas from the source directory, you may need to run "
"'python setup.py build_ext --force' to build the C extensions first."
Reported by Pylint.
Line: 27
Column: 5
try:
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
except ImportError as e: # pragma: no cover
module = e.name
raise ImportError(
f"C extension: {module} not built. If you want to import "
"pandas from the source directory, you may need to run "
"'python setup.py build_ext --force' to build the C extensions first."
) from e
Reported by Pylint.
Line: 34
Column: 1
"'python setup.py build_ext --force' to build the C extensions first."
) from e
from pandas._config import (
get_option,
set_option,
reset_option,
describe_option,
option_context,
Reported by Pylint.
Line: 44
Column: 1
)
# let init-time option registration happen
import pandas.core.config_init
from pandas.core.api import (
# dtype
Int8Dtype,
Int16Dtype,
Reported by Pylint.
Line: 46
Column: 1
# let init-time option registration happen
import pandas.core.config_init
from pandas.core.api import (
# dtype
Int8Dtype,
Int16Dtype,
Int32Dtype,
Int64Dtype,
Reported by Pylint.
Line: 114
Column: 1
DataFrame,
)
from pandas.core.arrays.sparse import SparseDtype
from pandas.tseries.api import infer_freq
from pandas.tseries import offsets
from pandas.core.computation.api import eval
Reported by Pylint.
Line: 116
Column: 1
from pandas.core.arrays.sparse import SparseDtype
from pandas.tseries.api import infer_freq
from pandas.tseries import offsets
from pandas.core.computation.api import eval
from pandas.core.reshape.api import (
Reported by Pylint.
pandas/tests/frame/methods/test_first_and_last.py
26 issues
Line: 4
Column: 1
"""
Note: includes tests for `last`
"""
import pytest
from pandas import (
DataFrame,
bdate_range,
)
Reported by Pylint.
Line: 13
Column: 1
import pandas._testing as tm
class TestFirst:
def test_first_subset(self, frame_or_series):
ts = tm.makeTimeDataFrame(freq="12h")
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
Reported by Pylint.
Line: 14
Column: 5
class TestFirst:
def test_first_subset(self, frame_or_series):
ts = tm.makeTimeDataFrame(freq="12h")
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
assert len(result) == 20
Reported by Pylint.
Line: 14
Column: 5
class TestFirst:
def test_first_subset(self, frame_or_series):
ts = tm.makeTimeDataFrame(freq="12h")
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
assert len(result) == 20
Reported by Pylint.
Line: 15
Column: 9
class TestFirst:
def test_first_subset(self, frame_or_series):
ts = tm.makeTimeDataFrame(freq="12h")
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
assert len(result) == 20
Reported by Pylint.
Line: 17
Column: 13
def test_first_subset(self, frame_or_series):
ts = tm.makeTimeDataFrame(freq="12h")
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
assert len(result) == 20
ts = tm.makeTimeDataFrame(freq="D")
if frame_or_series is not DataFrame:
Reported by Pylint.
Line: 19
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
assert len(result) == 20
ts = tm.makeTimeDataFrame(freq="D")
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
Reported by Bandit.
Line: 21
Column: 9
result = ts.first("10d")
assert len(result) == 20
ts = tm.makeTimeDataFrame(freq="D")
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
assert len(result) == 10
Reported by Pylint.
Line: 23
Column: 13
ts = tm.makeTimeDataFrame(freq="D")
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
assert len(result) == 10
result = ts.first("3M")
expected = ts[:"3/31/2000"]
Reported by Pylint.
Line: 25
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if frame_or_series is not DataFrame:
ts = ts["A"]
result = ts.first("10d")
assert len(result) == 10
result = ts.first("3M")
expected = ts[:"3/31/2000"]
tm.assert_equal(result, expected)
Reported by Bandit.
pandas/tests/arrays/timedeltas/test_constructors.py
26 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas.core.arrays import TimedeltaArray
class TestTimedeltaArrayConstructor:
def test_only_1dim_accepted(self):
# GH#25282
Reported by Pylint.
Line: 14
Column: 28
with pytest.raises(ValueError, match="Only 1-dimensional"):
# 3-dim, we allow 2D to sneak in for ops purposes GH#29853
TimedeltaArray(arr.reshape(2, 2, 1))
with pytest.raises(ValueError, match="Only 1-dimensional"):
# 0-dim
TimedeltaArray(arr[[0]].squeeze())
Reported by Pylint.
Line: 40
Column: 3
TimedeltaArray(np.array([1, 2, 3], dtype="bool"))
def test_incorrect_dtype_raises(self):
# TODO: why TypeError for 'category' but ValueError for i8?
with pytest.raises(
ValueError, match=r"category cannot be converted to timedelta64\[ns\]"
):
TimedeltaArray(np.array([1, 2, 3], dtype="i8"), dtype="category")
Reported by Pylint.
Line: 54
Column: 16
def test_copy(self):
data = np.array([1, 2, 3], dtype="m8[ns]")
arr = TimedeltaArray(data, copy=False)
assert arr._data is data
arr = TimedeltaArray(data, copy=True)
assert arr._data is not data
assert arr._data.base is not data
Reported by Pylint.
Line: 57
Column: 16
assert arr._data is data
arr = TimedeltaArray(data, copy=True)
assert arr._data is not data
assert arr._data.base is not data
def test_from_sequence_dtype(self):
msg = "dtype .*object.* cannot be converted to timedelta64"
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 58
Column: 16
arr = TimedeltaArray(data, copy=True)
assert arr._data is not data
assert arr._data.base is not data
def test_from_sequence_dtype(self):
msg = "dtype .*object.* cannot be converted to timedelta64"
with pytest.raises(ValueError, match=msg):
TimedeltaArray._from_sequence([], dtype=object)
Reported by Pylint.
Line: 63
Column: 13
def test_from_sequence_dtype(self):
msg = "dtype .*object.* cannot be converted to timedelta64"
with pytest.raises(ValueError, match=msg):
TimedeltaArray._from_sequence([], dtype=object)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas.core.arrays import TimedeltaArray
class TestTimedeltaArrayConstructor:
def test_only_1dim_accepted(self):
# GH#25282
Reported by Pylint.
Line: 7
Column: 1
from pandas.core.arrays import TimedeltaArray
class TestTimedeltaArrayConstructor:
def test_only_1dim_accepted(self):
# GH#25282
arr = np.array([0, 1, 2, 3], dtype="m8[h]").astype("m8[ns]")
with pytest.raises(ValueError, match="Only 1-dimensional"):
Reported by Pylint.
Line: 8
Column: 5
class TestTimedeltaArrayConstructor:
def test_only_1dim_accepted(self):
# GH#25282
arr = np.array([0, 1, 2, 3], dtype="m8[h]").astype("m8[ns]")
with pytest.raises(ValueError, match="Only 1-dimensional"):
# 3-dim, we allow 2D to sneak in for ops purposes GH#29853
Reported by Pylint.
pandas/tests/frame/test_cumulative.py
26 issues
Line: 24
Column: 3
def test_cumsum_corner(self):
dm = DataFrame(np.arange(20).reshape(4, 5), index=range(4), columns=range(5))
# TODO(wesm): do something with this?
result = dm.cumsum() # noqa
def test_cumsum(self, datetime_frame):
datetime_frame.iloc[5:10, 0] = np.nan
datetime_frame.iloc[10:15, 1] = np.nan
Reported by Pylint.
Line: 25
Column: 9
def test_cumsum_corner(self):
dm = DataFrame(np.arange(20).reshape(4, 5), index=range(4), columns=range(5))
# TODO(wesm): do something with this?
result = dm.cumsum() # noqa
def test_cumsum(self, datetime_frame):
datetime_frame.iloc[5:10, 0] = np.nan
datetime_frame.iloc[10:15, 1] = np.nan
datetime_frame.iloc[15:, 2] = np.nan
Reported by Pylint.
Line: 18
Column: 1
import pandas._testing as tm
class TestDataFrameCumulativeOps:
# ---------------------------------------------------------------------
# Cumulative Operations - cumsum, cummax, ...
def test_cumsum_corner(self):
dm = DataFrame(np.arange(20).reshape(4, 5), index=range(4), columns=range(5))
Reported by Pylint.
Line: 22
Column: 5
# ---------------------------------------------------------------------
# Cumulative Operations - cumsum, cummax, ...
def test_cumsum_corner(self):
dm = DataFrame(np.arange(20).reshape(4, 5), index=range(4), columns=range(5))
# TODO(wesm): do something with this?
result = dm.cumsum() # noqa
def test_cumsum(self, datetime_frame):
Reported by Pylint.
Line: 22
Column: 5
# ---------------------------------------------------------------------
# Cumulative Operations - cumsum, cummax, ...
def test_cumsum_corner(self):
dm = DataFrame(np.arange(20).reshape(4, 5), index=range(4), columns=range(5))
# TODO(wesm): do something with this?
result = dm.cumsum() # noqa
def test_cumsum(self, datetime_frame):
Reported by Pylint.
Line: 23
Column: 9
# Cumulative Operations - cumsum, cummax, ...
def test_cumsum_corner(self):
dm = DataFrame(np.arange(20).reshape(4, 5), index=range(4), columns=range(5))
# TODO(wesm): do something with this?
result = dm.cumsum() # noqa
def test_cumsum(self, datetime_frame):
datetime_frame.iloc[5:10, 0] = np.nan
Reported by Pylint.
Line: 27
Column: 5
# TODO(wesm): do something with this?
result = dm.cumsum() # noqa
def test_cumsum(self, datetime_frame):
datetime_frame.iloc[5:10, 0] = np.nan
datetime_frame.iloc[10:15, 1] = np.nan
datetime_frame.iloc[15:, 2] = np.nan
# axis = 0
Reported by Pylint.
Line: 27
Column: 5
# TODO(wesm): do something with this?
result = dm.cumsum() # noqa
def test_cumsum(self, datetime_frame):
datetime_frame.iloc[5:10, 0] = np.nan
datetime_frame.iloc[10:15, 1] = np.nan
datetime_frame.iloc[15:, 2] = np.nan
# axis = 0
Reported by Pylint.
Line: 43
Column: 9
tm.assert_frame_equal(cumsum, expected)
# works
df = DataFrame({"A": np.arange(20)}, index=np.arange(20))
df.cumsum()
# fix issue
cumsum_xs = datetime_frame.cumsum(axis=1)
assert np.shape(cumsum_xs) == np.shape(datetime_frame)
Reported by Pylint.
Line: 48
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# fix issue
cumsum_xs = datetime_frame.cumsum(axis=1)
assert np.shape(cumsum_xs) == np.shape(datetime_frame)
def test_cumprod(self, datetime_frame):
datetime_frame.iloc[5:10, 0] = np.nan
datetime_frame.iloc[10:15, 1] = np.nan
datetime_frame.iloc[15:, 2] = np.nan
Reported by Bandit.
pandas/tests/indexes/categorical/test_append.py
26 issues
Line: 1
Column: 1
import pytest
from pandas import (
CategoricalIndex,
Index,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import (
CategoricalIndex,
Index,
)
import pandas._testing as tm
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestAppend:
@pytest.fixture
def ci(self):
categories = list("cab")
return CategoricalIndex(list("aabbca"), categories=categories, ordered=False)
Reported by Pylint.
Line: 12
Column: 5
class TestAppend:
@pytest.fixture
def ci(self):
categories = list("cab")
return CategoricalIndex(list("aabbca"), categories=categories, ordered=False)
def test_append(self, ci):
# append cats with the same categories
Reported by Pylint.
Line: 12
Column: 5
class TestAppend:
@pytest.fixture
def ci(self):
categories = list("cab")
return CategoricalIndex(list("aabbca"), categories=categories, ordered=False)
def test_append(self, ci):
# append cats with the same categories
Reported by Pylint.
Line: 12
Column: 5
class TestAppend:
@pytest.fixture
def ci(self):
categories = list("cab")
return CategoricalIndex(list("aabbca"), categories=categories, ordered=False)
def test_append(self, ci):
# append cats with the same categories
Reported by Pylint.
Line: 16
Column: 5
categories = list("cab")
return CategoricalIndex(list("aabbca"), categories=categories, ordered=False)
def test_append(self, ci):
# append cats with the same categories
result = ci[:3].append(ci[3:])
tm.assert_index_equal(result, ci, exact=True)
foos = [ci[:1], ci[1:3], ci[3:]]
Reported by Pylint.
Line: 16
Column: 5
categories = list("cab")
return CategoricalIndex(list("aabbca"), categories=categories, ordered=False)
def test_append(self, ci):
# append cats with the same categories
result = ci[:3].append(ci[3:])
tm.assert_index_equal(result, ci, exact=True)
foos = [ci[:1], ci[1:3], ci[3:]]
Reported by Pylint.
Line: 16
Column: 5
categories = list("cab")
return CategoricalIndex(list("aabbca"), categories=categories, ordered=False)
def test_append(self, ci):
# append cats with the same categories
result = ci[:3].append(ci[3:])
tm.assert_index_equal(result, ci, exact=True)
foos = [ci[:1], ci[1:3], ci[3:]]
Reported by Pylint.
Line: 25
Column: 5
result = foos[0].append(foos[1:])
tm.assert_index_equal(result, ci, exact=True)
def test_append_empty(self, ci):
# empty
result = ci.append([])
tm.assert_index_equal(result, ci, exact=True)
def test_append_mismatched_categories(self, ci):
Reported by Pylint.