The following issues were found
asv_bench/benchmarks/hash_functions.py
39 issues
Line: 3
Column: 1
import numpy as np
import pandas as pd
class UniqueForLargePyObjectInts:
def setup(self):
lst = [x << 32 for x in range(5000)]
self.arr = np.array(lst, dtype=np.object_)
Reported by Pylint.
Line: 9
Column: 9
class UniqueForLargePyObjectInts:
def setup(self):
lst = [x << 32 for x in range(5000)]
self.arr = np.array(lst, dtype=np.object_)
def time_unique(self):
pd.unique(self.arr)
Reported by Pylint.
Line: 18
Column: 9
class Float64GroupIndex:
# GH28303
def setup(self):
self.df = pd.date_range(
start="1/1/2018", end="1/2/2018", periods=10 ** 6
).to_frame()
self.group_index = np.round(self.df.index.astype(int) / 10 ** 9)
def time_groupby(self):
Reported by Pylint.
Line: 21
Column: 9
self.df = pd.date_range(
start="1/1/2018", end="1/2/2018", periods=10 ** 6
).to_frame()
self.group_index = np.round(self.df.index.astype(int) / 10 ** 9)
def time_groupby(self):
self.df.groupby(self.group_index).last()
Reported by Pylint.
Line: 33
Column: 9
def setup(self, exponent):
a = np.arange(10 ** 4, dtype="float64")
self.a2 = (a + 10 ** exponent).repeat(100)
def time_factorize(self, exponent):
pd.factorize(self.a2)
def time_unique(self, exponent):
Reported by Pylint.
Line: 35
Column: 30
a = np.arange(10 ** 4, dtype="float64")
self.a2 = (a + 10 ** exponent).repeat(100)
def time_factorize(self, exponent):
pd.factorize(self.a2)
def time_unique(self, exponent):
pd.unique(self.a2)
Reported by Pylint.
Line: 38
Column: 27
def time_factorize(self, exponent):
pd.factorize(self.a2)
def time_unique(self, exponent):
pd.unique(self.a2)
class NumericSeriesIndexing:
Reported by Pylint.
Line: 53
Column: 9
def setup(self, index, N):
vals = np.array(list(range(55)) + [54] + list(range(55, N - 1)))
indices = index(vals)
self.data = pd.Series(np.arange(N), index=indices)
def time_loc_slice(self, index, N):
# trigger building of mapping
self.data.loc[:800]
Reported by Pylint.
Line: 55
Column: 37
indices = index(vals)
self.data = pd.Series(np.arange(N), index=indices)
def time_loc_slice(self, index, N):
# trigger building of mapping
self.data.loc[:800]
class NumericSeriesIndexingShuffled:
Reported by Pylint.
Line: 55
Column: 30
indices = index(vals)
self.data = pd.Series(np.arange(N), index=indices)
def time_loc_slice(self, index, N):
# trigger building of mapping
self.data.loc[:800]
class NumericSeriesIndexingShuffled:
Reported by Pylint.
pandas/tests/io/parser/test_read_fwf.py
39 issues
Line: 15
Column: 1
from pathlib import Path
import numpy as np
import pytest
from pandas.errors import EmptyDataError
from pandas import (
DataFrame,
Reported by Pylint.
Line: 31
Column: 1
)
def test_basic():
data = """\
A B C D
201158 360.242940 149.910199 11950.7
201159 444.953632 166.985655 11788.4
201160 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 54
Column: 1
tm.assert_frame_equal(result, expected)
def test_colspecs():
data = """\
A B C D E
201158 360.242940 149.910199 11950.7
201159 444.953632 166.985655 11788.4
201160 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 79
Column: 1
tm.assert_frame_equal(result, expected)
def test_widths():
data = """\
A B C D E
2011 58 360.242940 149.910199 11950.7
2011 59 444.953632 166.985655 11788.4
2011 60 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 103
Column: 1
tm.assert_frame_equal(result, expected)
def test_non_space_filler():
# From Thomas Kluyver:
#
# Apparently, some non-space filler characters can be seen, this is
# supported by specifying the 'delimiter' character:
#
Reported by Pylint.
Line: 134
Column: 1
tm.assert_frame_equal(result, expected)
def test_over_specified():
data = """\
A B C D E
201158 360.242940 149.910199 11950.7
201159 444.953632 166.985655 11788.4
201160 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 149
Column: 1
read_fwf(StringIO(data), colspecs=colspecs, widths=[6, 10, 10, 7])
def test_under_specified():
data = """\
A B C D E
201158 360.242940 149.910199 11950.7
201159 444.953632 166.985655 11788.4
201160 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 162
Column: 1
read_fwf(StringIO(data), colspecs=None, widths=None)
def test_read_csv_compat():
csv_data = """\
A,B,C,D,E
2011,58,360.242940,149.910199,11950.7
2011,59,444.953632,166.985655,11788.4
2011,60,364.136849,183.628767,11806.2
Reported by Pylint.
Line: 186
Column: 1
tm.assert_frame_equal(result, expected)
def test_bytes_io_input():
result = read_fwf(BytesIO("שלום\nשלום".encode()), widths=[2, 2], encoding="utf8")
expected = DataFrame([["של", "ום"]], columns=["של", "ום"])
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 192
Column: 1
tm.assert_frame_equal(result, expected)
def test_fwf_colspecs_is_list_or_tuple():
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.
pandas/tests/frame/methods/test_first_valid_index.py
39 issues
Line: 5
Column: 1
Includes test for last_valid_index.
"""
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
date_range,
Reported by Pylint.
Line: 15
Column: 1
import pandas._testing as tm
class TestFirstValidIndex:
def test_first_valid_index_single_nan(self, frame_or_series):
# GH#9752 Series/DataFrame should both return None, not raise
obj = frame_or_series([np.nan])
assert obj.first_valid_index() is None
Reported by Pylint.
Line: 16
Column: 5
class TestFirstValidIndex:
def test_first_valid_index_single_nan(self, frame_or_series):
# GH#9752 Series/DataFrame should both return None, not raise
obj = frame_or_series([np.nan])
assert obj.first_valid_index() is None
assert obj.iloc[:0].first_valid_index() is None
Reported by Pylint.
Line: 16
Column: 5
class TestFirstValidIndex:
def test_first_valid_index_single_nan(self, frame_or_series):
# GH#9752 Series/DataFrame should both return None, not raise
obj = frame_or_series([np.nan])
assert obj.first_valid_index() is None
assert obj.iloc[:0].first_valid_index() is None
Reported by Pylint.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# GH#9752 Series/DataFrame should both return None, not raise
obj = frame_or_series([np.nan])
assert obj.first_valid_index() is None
assert obj.iloc[:0].first_valid_index() is None
@pytest.mark.parametrize(
"empty", [DataFrame(), Series(dtype=object), Series([], index=[], dtype=object)]
)
Reported by Bandit.
Line: 21
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
obj = frame_or_series([np.nan])
assert obj.first_valid_index() is None
assert obj.iloc[:0].first_valid_index() is None
@pytest.mark.parametrize(
"empty", [DataFrame(), Series(dtype=object), Series([], index=[], dtype=object)]
)
def test_first_valid_index_empty(self, empty):
Reported by Bandit.
Line: 25
Column: 5
@pytest.mark.parametrize(
"empty", [DataFrame(), Series(dtype=object), Series([], index=[], dtype=object)]
)
def test_first_valid_index_empty(self, empty):
# GH#12800
assert empty.last_valid_index() is None
assert empty.first_valid_index() is None
Reported by Pylint.
Line: 25
Column: 5
@pytest.mark.parametrize(
"empty", [DataFrame(), Series(dtype=object), Series([], index=[], dtype=object)]
)
def test_first_valid_index_empty(self, empty):
# GH#12800
assert empty.last_valid_index() is None
assert empty.first_valid_index() is None
Reported by Pylint.
Line: 28
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_first_valid_index_empty(self, empty):
# GH#12800
assert empty.last_valid_index() is None
assert empty.first_valid_index() is None
@pytest.mark.parametrize(
"data,idx,expected_first,expected_last",
[
Reported by Bandit.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_first_valid_index_empty(self, empty):
# GH#12800
assert empty.last_valid_index() is None
assert empty.first_valid_index() is None
@pytest.mark.parametrize(
"data,idx,expected_first,expected_last",
[
({"A": [1, 2, 3]}, [1, 1, 2], 1, 2),
Reported by Bandit.
pandas/tests/indexes/multi/test_compat.py
38 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import MultiIndex
import pandas._testing as tm
def test_numeric_compat(idx):
with pytest.raises(TypeError, match="cannot perform __mul__"):
Reported by Pylint.
Line: 50
Column: 12
assert "_values" not in mi1._cache
assert "_values" not in mi2._cache
vals = mi1.values.copy()
vals2 = mi2.values.copy()
# accessing .values should cache ._values
assert mi1._values is mi1._cache["_values"]
assert mi1.values is mi1._cache["_values"]
Reported by Pylint.
Line: 51
Column: 13
assert "_values" not in mi2._cache
vals = mi1.values.copy()
vals2 = mi2.values.copy()
# accessing .values should cache ._values
assert mi1._values is mi1._cache["_values"]
assert mi1.values is mi1._cache["_values"]
assert isinstance(mi1._cache["_values"], np.ndarray)
Reported by Pylint.
Line: 10
Column: 9
def test_numeric_compat(idx):
with pytest.raises(TypeError, match="cannot perform __mul__"):
idx * 1
with pytest.raises(TypeError, match="cannot perform __rmul__"):
1 * idx
div_err = "cannot perform __truediv__"
Reported by Pylint.
Line: 13
Column: 9
idx * 1
with pytest.raises(TypeError, match="cannot perform __rmul__"):
1 * idx
div_err = "cannot perform __truediv__"
with pytest.raises(TypeError, match=div_err):
idx / 1
Reported by Pylint.
Line: 17
Column: 9
div_err = "cannot perform __truediv__"
with pytest.raises(TypeError, match=div_err):
idx / 1
div_err = div_err.replace(" __", " __r")
with pytest.raises(TypeError, match=div_err):
1 / idx
Reported by Pylint.
Line: 21
Column: 9
div_err = div_err.replace(" __", " __r")
with pytest.raises(TypeError, match=div_err):
1 / idx
with pytest.raises(TypeError, match="cannot perform __floordiv__"):
idx // 1
with pytest.raises(TypeError, match="cannot perform __rfloordiv__"):
Reported by Pylint.
Line: 24
Column: 9
1 / idx
with pytest.raises(TypeError, match="cannot perform __floordiv__"):
idx // 1
with pytest.raises(TypeError, match="cannot perform __rfloordiv__"):
1 // idx
Reported by Pylint.
Line: 27
Column: 9
idx // 1
with pytest.raises(TypeError, match="cannot perform __rfloordiv__"):
1 // idx
@pytest.mark.parametrize("method", ["all", "any"])
def test_logical_compat(idx, method):
msg = f"cannot perform {method}"
Reported by Pylint.
Line: 47
Column: 29
mi2 = MultiIndex(levels=levels2, codes=codes)
# instantiating MultiIndex should not access/cache _.values
assert "_values" not in mi1._cache
assert "_values" not in mi2._cache
vals = mi1.values.copy()
vals2 = mi2.values.copy()
Reported by Pylint.
pandas/tests/reshape/concat/test_categorical.py
38 issues
Line: 1
Column: 1
import numpy as np
from pandas.core.dtypes.dtypes import CategoricalDtype
import pandas as pd
from pandas import (
Categorical,
DataFrame,
Series,
Reported by Pylint.
Line: 14
Column: 1
import pandas._testing as tm
class TestCategoricalConcat:
def test_categorical_concat(self, sort):
# See GH 10177
df1 = DataFrame(
np.arange(18, dtype="int64").reshape(6, 3), columns=["a", "b", "c"]
)
Reported by Pylint.
Line: 15
Column: 5
class TestCategoricalConcat:
def test_categorical_concat(self, sort):
# See GH 10177
df1 = DataFrame(
np.arange(18, dtype="int64").reshape(6, 3), columns=["a", "b", "c"]
)
Reported by Pylint.
Line: 15
Column: 5
class TestCategoricalConcat:
def test_categorical_concat(self, sort):
# See GH 10177
df1 = DataFrame(
np.arange(18, dtype="int64").reshape(6, 3), columns=["a", "b", "c"]
)
Reported by Pylint.
Line: 52
Column: 5
exp["h"] = exp["h"].astype(df2["h"].dtype)
tm.assert_frame_equal(res, exp)
def test_categorical_concat_dtypes(self):
# GH8143
index = ["cat", "obj", "num"]
cat = Categorical(["a", "b", "c"])
obj = Series(["a", "b", "c"])
Reported by Pylint.
Line: 52
Column: 5
exp["h"] = exp["h"].astype(df2["h"].dtype)
tm.assert_frame_equal(res, exp)
def test_categorical_concat_dtypes(self):
# GH8143
index = ["cat", "obj", "num"]
cat = Categorical(["a", "b", "c"])
obj = Series(["a", "b", "c"])
Reported by Pylint.
Line: 59
Column: 9
cat = Categorical(["a", "b", "c"])
obj = Series(["a", "b", "c"])
num = Series([1, 2, 3])
df = pd.concat([Series(cat), obj, num], axis=1, keys=index)
result = df.dtypes == "object"
expected = Series([False, True, False], index=index)
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 73
Column: 5
expected = Series([True, False, False], index=index)
tm.assert_series_equal(result, expected)
def test_concat_categoricalindex(self):
# GH 16111, categories that aren't lexsorted
categories = [9, 0, 1, 2, 3]
a = Series(1, index=pd.CategoricalIndex([9, 0], categories=categories))
b = Series(2, index=pd.CategoricalIndex([0, 1], categories=categories))
Reported by Pylint.
Line: 73
Column: 5
expected = Series([True, False, False], index=index)
tm.assert_series_equal(result, expected)
def test_concat_categoricalindex(self):
# GH 16111, categories that aren't lexsorted
categories = [9, 0, 1, 2, 3]
a = Series(1, index=pd.CategoricalIndex([9, 0], categories=categories))
b = Series(2, index=pd.CategoricalIndex([0, 1], categories=categories))
Reported by Pylint.
Line: 77
Column: 9
# GH 16111, categories that aren't lexsorted
categories = [9, 0, 1, 2, 3]
a = Series(1, index=pd.CategoricalIndex([9, 0], categories=categories))
b = Series(2, index=pd.CategoricalIndex([0, 1], categories=categories))
c = Series(3, index=pd.CategoricalIndex([1, 2], categories=categories))
result = pd.concat([a, b, c], axis=1)
Reported by Pylint.
pandas/tests/frame/indexing/test_set_value.py
38 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas.core.dtypes.common import is_float_dtype
from pandas import (
DataFrame,
isna,
)
Reported by Pylint.
Line: 16
Column: 17
def test_set_value(self, float_frame):
for idx in float_frame.index:
for col in float_frame.columns:
float_frame._set_value(idx, col, 1)
assert float_frame[col][idx] == 1
def test_set_value_resize(self, float_frame):
res = float_frame._set_value("foobar", "B", 0)
Reported by Pylint.
Line: 21
Column: 15
def test_set_value_resize(self, float_frame):
res = float_frame._set_value("foobar", "B", 0)
assert res is None
assert float_frame.index[-1] == "foobar"
assert float_frame._get_value("foobar", "B") == 0
float_frame.loc["foobar", "qux"] = 0
Reported by Pylint.
Line: 24
Column: 16
res = float_frame._set_value("foobar", "B", 0)
assert res is None
assert float_frame.index[-1] == "foobar"
assert float_frame._get_value("foobar", "B") == 0
float_frame.loc["foobar", "qux"] = 0
assert float_frame._get_value("foobar", "qux") == 0
res = float_frame.copy()
Reported by Pylint.
Line: 27
Column: 16
assert float_frame._get_value("foobar", "B") == 0
float_frame.loc["foobar", "qux"] = 0
assert float_frame._get_value("foobar", "qux") == 0
res = float_frame.copy()
res._set_value("foobar", "baz", "sam")
assert res["baz"].dtype == np.object_
Reported by Pylint.
Line: 30
Column: 9
assert float_frame._get_value("foobar", "qux") == 0
res = float_frame.copy()
res._set_value("foobar", "baz", "sam")
assert res["baz"].dtype == np.object_
res = float_frame.copy()
res._set_value("foobar", "baz", True)
assert res["baz"].dtype == np.object_
Reported by Pylint.
Line: 34
Column: 9
assert res["baz"].dtype == np.object_
res = float_frame.copy()
res._set_value("foobar", "baz", True)
assert res["baz"].dtype == np.object_
res = float_frame.copy()
res._set_value("foobar", "baz", 5)
assert is_float_dtype(res["baz"])
Reported by Pylint.
Line: 38
Column: 9
assert res["baz"].dtype == np.object_
res = float_frame.copy()
res._set_value("foobar", "baz", 5)
assert is_float_dtype(res["baz"])
assert isna(res["baz"].drop(["foobar"])).all()
msg = "could not convert string to float: 'sam'"
with pytest.raises(ValueError, match=msg):
res._set_value("foobar", "baz", "sam")
Reported by Pylint.
Line: 43
Column: 13
assert isna(res["baz"].drop(["foobar"])).all()
msg = "could not convert string to float: 'sam'"
with pytest.raises(ValueError, match=msg):
res._set_value("foobar", "baz", "sam")
def test_set_value_with_index_dtype_change(self):
df_orig = DataFrame(np.random.randn(3, 3), index=range(3), columns=list("ABC"))
# this is actually ambiguous as the 2 is interpreted as a positional
Reported by Pylint.
Line: 51
Column: 9
# this is actually ambiguous as the 2 is interpreted as a positional
# so column is not created
df = df_orig.copy()
df._set_value("C", 2, 1.0)
assert list(df.index) == list(df_orig.index) + ["C"]
# assert list(df.columns) == list(df_orig.columns) + [2]
df = df_orig.copy()
df.loc["C", 2] = 1.0
Reported by Pylint.
pandas/tests/extension/test_interval.py
38 issues
Line: 17
Column: 1
"""
import numpy as np
import pytest
from pandas.core.dtypes.dtypes import IntervalDtype
from pandas import Interval
from pandas.core.arrays import IntervalArray
Reported by Pylint.
Line: 98
Column: 25
class TestInterface(BaseInterval, base.BaseInterfaceTests):
def test_view(self, data):
# __setitem__ incorrectly makes a copy (GH#27147), so we only
# have a smoke-test
data.view()
Reported by Pylint.
Line: 114
Column: 43
pass
@pytest.mark.skip(reason="Not Applicable")
def test_fillna_length_mismatch(self, data_missing):
pass
class TestMissing(BaseInterval, base.BaseMissingTests):
# Index.fillna only accepts scalar `value`, so we have to skip all
Reported by Pylint.
Line: 124
Column: 5
unsupported_fill = pytest.mark.skip("Unsupported fillna option.")
@unsupported_fill
def test_fillna_limit_pad(self):
pass
@unsupported_fill
def test_fillna_series_method(self):
pass
Reported by Pylint.
Line: 128
Column: 5
pass
@unsupported_fill
def test_fillna_series_method(self):
pass
@unsupported_fill
def test_fillna_limit_backfill(self):
pass
Reported by Pylint.
Line: 132
Column: 5
pass
@unsupported_fill
def test_fillna_limit_backfill(self):
pass
@unsupported_fill
def test_fillna_no_op_returns_copy(self):
pass
Reported by Pylint.
Line: 136
Column: 5
pass
@unsupported_fill
def test_fillna_no_op_returns_copy(self):
pass
@unsupported_fill
def test_fillna_series(self):
pass
Reported by Pylint.
Line: 140
Column: 5
pass
@unsupported_fill
def test_fillna_series(self):
pass
def test_fillna_non_scalar_raises(self, data_missing):
msg = "can only insert Interval objects and NA into an IntervalArray"
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 143
Column: 45
def test_fillna_series(self):
pass
def test_fillna_non_scalar_raises(self, data_missing):
msg = "can only insert Interval objects and NA into an IntervalArray"
with pytest.raises(TypeError, match=msg):
data_missing.fillna([1, 1])
Reported by Pylint.
Line: 159
Column: 31
class TestPrinting(BaseInterval, base.BasePrintingTests):
@pytest.mark.skip(reason="custom repr")
def test_array_repr(self, data, size):
pass
class TestParsing(BaseInterval, base.BaseParsingTests):
@pytest.mark.parametrize("engine", ["c", "python"])
Reported by Pylint.
pandas/tests/extension/arrow/test_bool.py
38 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.api.types import is_bool_dtype
from pandas.tests.extension import base
pytest.importorskip("pyarrow", minversion="0.13.0")
Reported by Pylint.
Line: 34
Column: 23
return ArrowBoolArray.from_scalars([None, True])
def test_basic_equals(data):
# https://github.com/pandas-dev/pandas/issues/34660
assert pd.Series(data).equals(pd.Series(data))
class BaseArrowTests:
Reported by Pylint.
Line: 44
Column: 40
class TestDtype(BaseArrowTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
pytest.skip("GH-22666")
class TestInterface(BaseArrowTests, base.BaseInterfaceTests):
def test_copy(self, data):
Reported by Pylint.
Line: 44
Column: 46
class TestDtype(BaseArrowTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
pytest.skip("GH-22666")
class TestInterface(BaseArrowTests, base.BaseInterfaceTests):
def test_copy(self, data):
Reported by Pylint.
Line: 44
Column: 40
class TestDtype(BaseArrowTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
pytest.skip("GH-22666")
class TestInterface(BaseArrowTests, base.BaseInterfaceTests):
def test_copy(self, data):
Reported by Pylint.
Line: 44
Column: 46
class TestDtype(BaseArrowTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
pytest.skip("GH-22666")
class TestInterface(BaseArrowTests, base.BaseInterfaceTests):
def test_copy(self, data):
Reported by Pylint.
Line: 49
Column: 25
class TestInterface(BaseArrowTests, base.BaseInterfaceTests):
def test_copy(self, data):
# __setitem__ does not work, so we only have a smoke-test
data.copy()
def test_view(self, data):
# __setitem__ does not work, so we only have a smoke-test
Reported by Pylint.
Line: 53
Column: 25
# __setitem__ does not work, so we only have a smoke-test
data.copy()
def test_view(self, data):
# __setitem__ does not work, so we only have a smoke-test
data.view()
@pytest.mark.xfail(raises=AssertionError, reason="Not implemented yet")
def test_contains(self, data, data_missing):
Reported by Pylint.
Line: 58
Column: 29
data.view()
@pytest.mark.xfail(raises=AssertionError, reason="Not implemented yet")
def test_contains(self, data, data_missing):
super().test_contains(data, data_missing)
class TestConstructors(BaseArrowTests, base.BaseConstructorsTests):
def test_from_dtype(self, data):
Reported by Pylint.
Line: 58
Column: 35
data.view()
@pytest.mark.xfail(raises=AssertionError, reason="Not implemented yet")
def test_contains(self, data, data_missing):
super().test_contains(data, data_missing)
class TestConstructors(BaseArrowTests, base.BaseConstructorsTests):
def test_from_dtype(self, data):
Reported by Pylint.
pandas/core/reshape/pivot.py
38 issues
Line: 183
Column: 3
if isinstance(agged[v], ABCDataFrame):
# exclude DataFrame case bc maybe_downcast_to_dtype expects
# ArrayLike
# TODO: why does test_pivot_table_doctest_case fail if
# we don't do this apparently-unnecessary setitem?
agged[v] = agged[v]
else:
agged[v] = maybe_downcast_to_dtype(agged[v], data[v].dtype)
Reported by Pylint.
Line: 511
Column: 23
if is_list_like(values) and not isinstance(values, tuple):
# Exclude tuple because it is seen as a single column name
values = cast(Sequence[Hashable], values)
indexed = data._constructor(
data[values]._values, index=multiindex, columns=values
)
else:
indexed = data._constructor_sliced(data[values]._values, index=multiindex)
return indexed.unstack(columns_listlike)
Reported by Pylint.
Line: 512
Column: 17
# Exclude tuple because it is seen as a single column name
values = cast(Sequence[Hashable], values)
indexed = data._constructor(
data[values]._values, index=multiindex, columns=values
)
else:
indexed = data._constructor_sliced(data[values]._values, index=multiindex)
return indexed.unstack(columns_listlike)
Reported by Pylint.
Line: 515
Column: 23
data[values]._values, index=multiindex, columns=values
)
else:
indexed = data._constructor_sliced(data[values]._values, index=multiindex)
return indexed.unstack(columns_listlike)
def crosstab(
index,
Reported by Pylint.
Line: 515
Column: 48
data[values]._values, index=multiindex, columns=values
)
else:
indexed = data._constructor_sliced(data[values]._values, index=multiindex)
return indexed.unstack(columns_listlike)
def crosstab(
index,
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from typing import (
TYPE_CHECKING,
Callable,
Hashable,
Sequence,
cast,
)
Reported by Pylint.
Line: 55
Column: 1
# _shared_docs['pivot_table'] will not yet exist. TODO: Fix this dependency
@Substitution("\ndata : DataFrame")
@Appender(_shared_docs["pivot_table"], indents=1)
def pivot_table(
data: DataFrame,
values=None,
index=None,
columns=None,
aggfunc: AggFuncType = "mean",
Reported by Pylint.
Line: 55
Column: 1
# _shared_docs['pivot_table'] will not yet exist. TODO: Fix this dependency
@Substitution("\ndata : DataFrame")
@Appender(_shared_docs["pivot_table"], indents=1)
def pivot_table(
data: DataFrame,
values=None,
index=None,
columns=None,
aggfunc: AggFuncType = "mean",
Reported by Pylint.
Line: 55
Column: 1
# _shared_docs['pivot_table'] will not yet exist. TODO: Fix this dependency
@Substitution("\ndata : DataFrame")
@Appender(_shared_docs["pivot_table"], indents=1)
def pivot_table(
data: DataFrame,
values=None,
index=None,
columns=None,
aggfunc: AggFuncType = "mean",
Reported by Pylint.
Line: 110
Column: 1
return table.__finalize__(data, method="pivot_table")
def __internal_pivot_table(
data: DataFrame,
values,
index,
columns,
aggfunc: AggFuncTypeBase | AggFuncTypeDict,
Reported by Pylint.
asv_bench/benchmarks/tslibs/period.py
38 issues
Line: 8
Column: 1
import numpy as np
from pandas._libs.tslibs.period import (
Period,
periodarr_to_dt64arr,
)
from pandas.tseries.frequencies import to_offset
Reported by Pylint.
Line: 13
Column: 1
periodarr_to_dt64arr,
)
from pandas.tseries.frequencies import to_offset
from .tslib import (
_sizes,
_tzs,
tzlocal_obj,
Reported by Pylint.
Line: 15
Column: 1
from pandas.tseries.frequencies import to_offset
from .tslib import (
_sizes,
_tzs,
tzlocal_obj,
)
Reported by Pylint.
Line: 51
Column: 27
)
param_names = ["freq", "attr"]
def setup(self, freq, attr):
self.per = Period("2012-06-01", freq=freq)
def time_property(self, freq, attr):
getattr(self.per, attr)
Reported by Pylint.
Line: 52
Column: 9
param_names = ["freq", "attr"]
def setup(self, freq, attr):
self.per = Period("2012-06-01", freq=freq)
def time_property(self, freq, attr):
getattr(self.per, attr)
Reported by Pylint.
Line: 54
Column: 29
def setup(self, freq, attr):
self.per = Period("2012-06-01", freq=freq)
def time_property(self, freq, attr):
getattr(self.per, attr)
class PeriodUnaryMethods:
Reported by Pylint.
Line: 64
Column: 9
param_names = ["freq"]
def setup(self, freq):
self.per = Period("2012-06-01", freq=freq)
def time_to_timestamp(self, freq):
self.per.to_timestamp()
def time_now(self, freq):
Reported by Pylint.
Line: 66
Column: 33
def setup(self, freq):
self.per = Period("2012-06-01", freq=freq)
def time_to_timestamp(self, freq):
self.per.to_timestamp()
def time_now(self, freq):
self.per.now(freq)
Reported by Pylint.
Line: 72
Column: 27
def time_now(self, freq):
self.per.now(freq)
def time_asfreq(self, freq):
self.per.asfreq("A")
class PeriodConstructor:
params = [["D"], [True, False]]
Reported by Pylint.
Line: 82
Column: 13
def setup(self, freq, is_offset):
if is_offset:
self.freq = to_offset(freq)
else:
self.freq = freq
def time_period_constructor(self, freq, is_offset):
Period("2012-06-01", freq=freq)
Reported by Pylint.