The following issues were found
pandas/tests/resample/test_deprecated.py
34 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 83
Column: 43
@all_ts
@pytest.mark.parametrize("arg", ["mean", {"value": "mean"}, ["mean"]])
def test_resample_loffset_arg_type(frame, create_index, arg):
# GH 13218, 15002
df = frame
expected_means = [df.values[i : i + 2].mean() for i in range(0, len(df.values), 2)]
expected_index = create_index(df.index[0], periods=len(df.index) / 2, freq="2D")
Reported by Pylint.
Line: 262
Column: 3
with tm.assert_produces_warning(FutureWarning):
expected = s.to_timestamp().resample(end_freq, base=base).mean()
if end_freq == "M":
# TODO: is non-tick the relevant characteristic? (GH 33815)
expected.index = expected.index._with_freq(None)
tm.assert_series_equal(result, expected)
def test_resample_base_with_timedeltaindex():
Reported by Pylint.
Line: 263
Column: 26
expected = s.to_timestamp().resample(end_freq, base=base).mean()
if end_freq == "M":
# TODO: is non-tick the relevant characteristic? (GH 33815)
expected.index = expected.index._with_freq(None)
tm.assert_series_equal(result, expected)
def test_resample_base_with_timedeltaindex():
# GH 10530
Reported by Pylint.
Line: 306
Column: 5
)
expected = Series([1.0, 1.0, 1.0, 1.0], index=idx)
expected.index._data.freq = "3s"
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 1
Column: 1
from datetime import (
datetime,
timedelta,
)
import numpy as np
import pytest
import pandas as pd
Reported by Pylint.
Line: 43
Column: 1
@pytest.fixture
def create_index(_index_factory):
def _create_index(*args, **kwargs):
"""return the _index_factory created using the args, kwargs"""
return _index_factory(*args, **kwargs)
return _create_index
Reported by Pylint.
Line: 52
Column: 1
# new test to check that all FutureWarning are triggered
def test_deprecating_on_loffset_and_base():
# GH 31809
idx = date_range("2001-01-01", periods=4, freq="T")
df = DataFrame(data=4 * [range(2)], index=idx, columns=["a", "b"])
Reported by Pylint.
Line: 56
Column: 5
# GH 31809
idx = date_range("2001-01-01", periods=4, freq="T")
df = DataFrame(data=4 * [range(2)], index=idx, columns=["a", "b"])
with tm.assert_produces_warning(FutureWarning):
pd.Grouper(freq="10s", base=0)
with tm.assert_produces_warning(FutureWarning):
pd.Grouper(freq="10s", loffset="0s")
Reported by Pylint.
Line: 83
Column: 1
@all_ts
@pytest.mark.parametrize("arg", ["mean", {"value": "mean"}, ["mean"]])
def test_resample_loffset_arg_type(frame, create_index, arg):
# GH 13218, 15002
df = frame
expected_means = [df.values[i : i + 2].mean() for i in range(0, len(df.values), 2)]
expected_index = create_index(df.index[0], periods=len(df.index) / 2, freq="2D")
Reported by Pylint.
pandas/tests/arrays/floating/test_astype.py
34 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_astype():
# with missing values
Reported by Pylint.
Line: 81
Column: 33
# copy=True -> ensure both data and mask are actual copies
result = arr.astype("Float64", copy=True)
assert result is not arr
assert not np.shares_memory(result._data, arr._data)
assert not np.shares_memory(result._mask, arr._mask)
result[0] = 10
tm.assert_extension_array_equal(arr, orig)
result[0] = pd.NA
tm.assert_extension_array_equal(arr, orig)
Reported by Pylint.
Line: 81
Column: 47
# copy=True -> ensure both data and mask are actual copies
result = arr.astype("Float64", copy=True)
assert result is not arr
assert not np.shares_memory(result._data, arr._data)
assert not np.shares_memory(result._mask, arr._mask)
result[0] = 10
tm.assert_extension_array_equal(arr, orig)
result[0] = pd.NA
tm.assert_extension_array_equal(arr, orig)
Reported by Pylint.
Line: 82
Column: 47
result = arr.astype("Float64", copy=True)
assert result is not arr
assert not np.shares_memory(result._data, arr._data)
assert not np.shares_memory(result._mask, arr._mask)
result[0] = 10
tm.assert_extension_array_equal(arr, orig)
result[0] = pd.NA
tm.assert_extension_array_equal(arr, orig)
Reported by Pylint.
Line: 82
Column: 33
result = arr.astype("Float64", copy=True)
assert result is not arr
assert not np.shares_memory(result._data, arr._data)
assert not np.shares_memory(result._mask, arr._mask)
result[0] = 10
tm.assert_extension_array_equal(arr, orig)
result[0] = pd.NA
tm.assert_extension_array_equal(arr, orig)
Reported by Pylint.
Line: 91
Column: 29
# copy=False
result = arr.astype("Float64", copy=False)
assert result is arr
assert np.shares_memory(result._data, arr._data)
assert np.shares_memory(result._mask, arr._mask)
result[0] = 10
assert arr[0] == 10
result[0] = pd.NA
assert arr[0] is pd.NA
Reported by Pylint.
Line: 91
Column: 43
# copy=False
result = arr.astype("Float64", copy=False)
assert result is arr
assert np.shares_memory(result._data, arr._data)
assert np.shares_memory(result._mask, arr._mask)
result[0] = 10
assert arr[0] == 10
result[0] = pd.NA
assert arr[0] is pd.NA
Reported by Pylint.
Line: 92
Column: 43
result = arr.astype("Float64", copy=False)
assert result is arr
assert np.shares_memory(result._data, arr._data)
assert np.shares_memory(result._mask, arr._mask)
result[0] = 10
assert arr[0] == 10
result[0] = pd.NA
assert arr[0] is pd.NA
Reported by Pylint.
Line: 92
Column: 29
result = arr.astype("Float64", copy=False)
assert result is arr
assert np.shares_memory(result._data, arr._data)
assert np.shares_memory(result._mask, arr._mask)
result[0] = 10
assert arr[0] == 10
result[0] = pd.NA
assert arr[0] is pd.NA
Reported by Pylint.
Line: 104
Column: 33
orig = pd.array([0.1, 0.2, None], dtype="Float64")
result = arr.astype("Float32", copy=False)
assert not np.shares_memory(result._data, arr._data)
assert not np.shares_memory(result._mask, arr._mask)
result[0] = 10
tm.assert_extension_array_equal(arr, orig)
result[0] = pd.NA
tm.assert_extension_array_equal(arr, orig)
Reported by Pylint.
pandas/tests/test_flags.py
34 issues
Line: 1
Column: 1
import pytest
import pandas as pd
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
Reported by Pylint.
Line: 45
Column: 13
assert flags["allows_duplicate_labels"] is False
with pytest.raises(KeyError, match="a"):
flags["a"]
with pytest.raises(ValueError, match="a"):
flags["a"] = 10
Reported by Pylint.
Line: 1
Column: 1
import pytest
import pandas as pd
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
Reported by Pylint.
Line: 6
Column: 1
import pandas as pd
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
Reported by Pylint.
Line: 7
Column: 5
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
Reported by Pylint.
Line: 7
Column: 5
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
Reported by Pylint.
Line: 8
Column: 9
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
assert a != b
Reported by Pylint.
Line: 9
Column: 9
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
assert a != b
assert a != 2
Reported by Pylint.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
assert a != b
assert a != 2
def test_set(self):
Reported by Bandit.
Line: 11
Column: 16
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
assert a != b
assert a != 2
def test_set(self):
Reported by Pylint.
pandas/tests/arrays/boolean/test_function.py
34 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize(
"ufunc", [np.add, np.logical_or, np.logical_and, np.logical_xor]
Reported by Pylint.
Line: 15
Column: 40
# two BooleanArrays
a = pd.array([True, False, None], dtype="boolean")
result = ufunc(a, a)
expected = pd.array(ufunc(a._data, a._data), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_extension_array_equal(result, expected)
s = pd.Series(a)
result = ufunc(s, a)
Reported by Pylint.
Line: 15
Column: 31
# two BooleanArrays
a = pd.array([True, False, None], dtype="boolean")
result = ufunc(a, a)
expected = pd.array(ufunc(a._data, a._data), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_extension_array_equal(result, expected)
s = pd.Series(a)
result = ufunc(s, a)
Reported by Pylint.
Line: 16
Column: 14
a = pd.array([True, False, None], dtype="boolean")
result = ufunc(a, a)
expected = pd.array(ufunc(a._data, a._data), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_extension_array_equal(result, expected)
s = pd.Series(a)
result = ufunc(s, a)
expected = pd.Series(ufunc(a._data, a._data), dtype="boolean")
Reported by Pylint.
Line: 21
Column: 32
s = pd.Series(a)
result = ufunc(s, a)
expected = pd.Series(ufunc(a._data, a._data), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_series_equal(result, expected)
# Boolean with numpy array
arr = np.array([True, True, False])
Reported by Pylint.
Line: 21
Column: 41
s = pd.Series(a)
result = ufunc(s, a)
expected = pd.Series(ufunc(a._data, a._data), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_series_equal(result, expected)
# Boolean with numpy array
arr = np.array([True, True, False])
Reported by Pylint.
Line: 22
Column: 14
s = pd.Series(a)
result = ufunc(s, a)
expected = pd.Series(ufunc(a._data, a._data), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_series_equal(result, expected)
# Boolean with numpy array
arr = np.array([True, True, False])
result = ufunc(a, arr)
Reported by Pylint.
Line: 28
Column: 31
# Boolean with numpy array
arr = np.array([True, True, False])
result = ufunc(a, arr)
expected = pd.array(ufunc(a._data, arr), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_extension_array_equal(result, expected)
result = ufunc(arr, a)
expected = pd.array(ufunc(arr, a._data), dtype="boolean")
Reported by Pylint.
Line: 29
Column: 14
arr = np.array([True, True, False])
result = ufunc(a, arr)
expected = pd.array(ufunc(a._data, arr), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_extension_array_equal(result, expected)
result = ufunc(arr, a)
expected = pd.array(ufunc(arr, a._data), dtype="boolean")
expected[a._mask] = np.nan
Reported by Pylint.
Line: 33
Column: 36
tm.assert_extension_array_equal(result, expected)
result = ufunc(arr, a)
expected = pd.array(ufunc(arr, a._data), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_extension_array_equal(result, expected)
# BooleanArray with scalar
result = ufunc(a, True)
Reported by Pylint.
pandas/tests/frame/methods/test_update.py
34 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Series,
date_range,
)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Series,
date_range,
)
Reported by Pylint.
Line: 13
Column: 1
import pandas._testing as tm
class TestDataFrameUpdate:
def test_update_nan(self):
# #15593 #15617
# test 1
df1 = DataFrame({"A": [1.0, 2, 3], "B": date_range("2000", periods=3)})
df2 = DataFrame({"A": [None, 2, 3]})
Reported by Pylint.
Line: 14
Column: 5
class TestDataFrameUpdate:
def test_update_nan(self):
# #15593 #15617
# test 1
df1 = DataFrame({"A": [1.0, 2, 3], "B": date_range("2000", periods=3)})
df2 = DataFrame({"A": [None, 2, 3]})
expected = df1.copy()
Reported by Pylint.
Line: 14
Column: 5
class TestDataFrameUpdate:
def test_update_nan(self):
# #15593 #15617
# test 1
df1 = DataFrame({"A": [1.0, 2, 3], "B": date_range("2000", periods=3)})
df2 = DataFrame({"A": [None, 2, 3]})
expected = df1.copy()
Reported by Pylint.
Line: 32
Column: 5
tm.assert_frame_equal(df1, expected)
def test_update(self):
df = DataFrame(
[[1.5, np.nan, 3.0], [1.5, np.nan, 3.0], [1.5, np.nan, 3], [1.5, np.nan, 3]]
)
other = DataFrame([[3.6, 2.0, np.nan], [np.nan, np.nan, 7]], index=[1, 3])
Reported by Pylint.
Line: 32
Column: 5
tm.assert_frame_equal(df1, expected)
def test_update(self):
df = DataFrame(
[[1.5, np.nan, 3.0], [1.5, np.nan, 3.0], [1.5, np.nan, 3], [1.5, np.nan, 3]]
)
other = DataFrame([[3.6, 2.0, np.nan], [np.nan, np.nan, 7]], index=[1, 3])
Reported by Pylint.
Line: 33
Column: 9
tm.assert_frame_equal(df1, expected)
def test_update(self):
df = DataFrame(
[[1.5, np.nan, 3.0], [1.5, np.nan, 3.0], [1.5, np.nan, 3], [1.5, np.nan, 3]]
)
other = DataFrame([[3.6, 2.0, np.nan], [np.nan, np.nan, 7]], index=[1, 3])
Reported by Pylint.
Line: 46
Column: 5
)
tm.assert_frame_equal(df, expected)
def test_update_dtypes(self):
# gh 3016
df = DataFrame(
[[1.0, 2.0, False, True], [4.0, 5.0, True, False]],
columns=["A", "B", "bool1", "bool2"],
Reported by Pylint.
Line: 46
Column: 5
)
tm.assert_frame_equal(df, expected)
def test_update_dtypes(self):
# gh 3016
df = DataFrame(
[[1.0, 2.0, False, True], [4.0, 5.0, True, False]],
columns=["A", "B", "bool1", "bool2"],
Reported by Pylint.
pandas/tests/indexes/object/test_indexing.py
34 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
import pandas as pd
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
import pandas as pd
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
import pandas as pd
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
import pandas as pd
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestGetLoc:
def test_get_loc_raises_object_nearest(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
Reported by Pylint.
Line: 12
Column: 5
class TestGetLoc:
def test_get_loc_raises_object_nearest(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
Reported by Pylint.
Line: 12
Column: 5
class TestGetLoc:
def test_get_loc_raises_object_nearest(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
Reported by Pylint.
Line: 18
Column: 5
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
def test_get_loc_raises_object_tolerance(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="pad", tolerance="invalid")
Reported by Pylint.
Line: 18
Column: 5
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
def test_get_loc_raises_object_tolerance(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="pad", tolerance="invalid")
Reported by Pylint.
Line: 25
Column: 1
index.get_loc("a", method="pad", tolerance="invalid")
class TestGetIndexer:
@pytest.mark.parametrize(
"method,expected",
[
("pad", np.array([-1, 0, 1, 1], dtype=np.intp)),
("backfill", np.array([0, 0, 1, -1], dtype=np.intp)),
Reported by Pylint.
pandas/tests/indexes/multi/test_analytics.py
34 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Index,
MultiIndex,
date_range,
period_range,
Reported by Pylint.
Line: 18
Column: 5
# GH8083 test the base class for shift
msg = "This method is only implemented for DatetimeIndex, PeriodIndex and "
"TimedeltaIndex; Got type MultiIndex"
with pytest.raises(NotImplementedError, match=msg):
idx.shift(1)
with pytest.raises(NotImplementedError, match=msg):
idx.shift(1, 2)
Reported by Pylint.
Line: 70
Column: 3
index.truncate(3, 1)
# TODO: reshape
def test_reorder_levels(idx):
# this blows up
with pytest.raises(IndexError, match="^Too many levels"):
Reported by Pylint.
Line: 162
Column: 9
# - now raises (previously was set op difference)
msg = "cannot perform __sub__ with this index type: MultiIndex"
with pytest.raises(TypeError, match=msg):
first - idx[-3:]
with pytest.raises(TypeError, match=msg):
idx[-3:] - first
with pytest.raises(TypeError, match=msg):
idx[-3:] - first.tolist()
msg = "cannot perform __rsub__ with this index type: MultiIndex"
Reported by Pylint.
Line: 164
Column: 9
with pytest.raises(TypeError, match=msg):
first - idx[-3:]
with pytest.raises(TypeError, match=msg):
idx[-3:] - first
with pytest.raises(TypeError, match=msg):
idx[-3:] - first.tolist()
msg = "cannot perform __rsub__ with this index type: MultiIndex"
with pytest.raises(TypeError, match=msg):
first.tolist() - idx[-3:]
Reported by Pylint.
Line: 166
Column: 9
with pytest.raises(TypeError, match=msg):
idx[-3:] - first
with pytest.raises(TypeError, match=msg):
idx[-3:] - first.tolist()
msg = "cannot perform __rsub__ with this index type: MultiIndex"
with pytest.raises(TypeError, match=msg):
first.tolist() - idx[-3:]
Reported by Pylint.
Line: 169
Column: 9
idx[-3:] - first.tolist()
msg = "cannot perform __rsub__ with this index type: MultiIndex"
with pytest.raises(TypeError, match=msg):
first.tolist() - idx[-3:]
def test_map(idx):
# callable
index = idx
Reported by Pylint.
Line: 190
Column: 9
"mapper",
[
lambda values, idx: {i: e for e, i in zip(values, idx)},
lambda values, idx: pd.Series(values, idx),
],
)
def test_map_dictlike(idx, mapper):
if isinstance(idx, (pd.CategoricalIndex, pd.IntervalIndex)):
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Index,
MultiIndex,
date_range,
period_range,
Reported by Pylint.
Line: 14
Column: 1
import pandas._testing as tm
def test_shift(idx):
# GH8083 test the base class for shift
msg = "This method is only implemented for DatetimeIndex, PeriodIndex and "
"TimedeltaIndex; Got type MultiIndex"
with pytest.raises(NotImplementedError, match=msg):
Reported by Pylint.
pandas/tests/frame/methods/test_asfreq.py
33 issues
Line: 42
Column: 9
tm.assert_almost_equal(offset_monthly["A"], rule_monthly["A"])
filled = rule_monthly.asfreq("B", method="pad") # noqa
# TODO: actually check that this worked.
# don't forget!
filled_dep = rule_monthly.asfreq("B", method="pad") # noqa
Reported by Pylint.
Line: 43
Column: 3
tm.assert_almost_equal(offset_monthly["A"], rule_monthly["A"])
filled = rule_monthly.asfreq("B", method="pad") # noqa
# TODO: actually check that this worked.
# don't forget!
filled_dep = rule_monthly.asfreq("B", method="pad") # noqa
# test does not blow up on length-0 DataFrame
Reported by Pylint.
Line: 46
Column: 9
# TODO: actually check that this worked.
# don't forget!
filled_dep = rule_monthly.asfreq("B", method="pad") # noqa
# test does not blow up on length-0 DataFrame
zero_length = datetime_frame.reindex([])
result = zero_length.asfreq("BM")
assert result is not zero_length
Reported by Pylint.
Line: 102
Column: 26
result = frame_or_series(range(4), index=index)
expected = result.reindex(sorted(index))
expected.index = expected.index._with_freq("infer")
result = result.asfreq("D")
tm.assert_equal(result, expected)
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
import numpy as np
from pandas import (
DataFrame,
DatetimeIndex,
Series,
date_range,
Reported by Pylint.
Line: 17
Column: 1
from pandas.tseries import offsets
class TestAsFreq:
def test_asfreq_resample_set_correct_freq(self):
# GH#5613
# we test if .asfreq() and .resample() set the correct value for .freq
df = DataFrame(
{"date": ["2012-01-01", "2012-01-02", "2012-01-03"], "col": [1, 2, 3]}
Reported by Pylint.
Line: 18
Column: 5
class TestAsFreq:
def test_asfreq_resample_set_correct_freq(self):
# GH#5613
# we test if .asfreq() and .resample() set the correct value for .freq
df = DataFrame(
{"date": ["2012-01-01", "2012-01-02", "2012-01-03"], "col": [1, 2, 3]}
)
Reported by Pylint.
Line: 18
Column: 5
class TestAsFreq:
def test_asfreq_resample_set_correct_freq(self):
# GH#5613
# we test if .asfreq() and .resample() set the correct value for .freq
df = DataFrame(
{"date": ["2012-01-01", "2012-01-02", "2012-01-03"], "col": [1, 2, 3]}
)
Reported by Pylint.
Line: 21
Column: 9
def test_asfreq_resample_set_correct_freq(self):
# GH#5613
# we test if .asfreq() and .resample() set the correct value for .freq
df = DataFrame(
{"date": ["2012-01-01", "2012-01-02", "2012-01-03"], "col": [1, 2, 3]}
)
df = df.set_index(to_datetime(df.date))
# testing the settings before calling .asfreq() and .resample()
Reported by Pylint.
Line: 24
Column: 9
df = DataFrame(
{"date": ["2012-01-01", "2012-01-02", "2012-01-03"], "col": [1, 2, 3]}
)
df = df.set_index(to_datetime(df.date))
# testing the settings before calling .asfreq() and .resample()
assert df.index.freq is None
assert df.index.inferred_freq == "D"
Reported by Pylint.
pandas/tests/reshape/test_util.py
33 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Index,
date_range,
)
import pandas._testing as tm
from pandas.core.reshape.util import cartesian_product
Reported by Pylint.
Line: 25
Column: 29
# regression test for GitHub issue #6439
# make sure that the ordering on datetimeindex is consistent
x = date_range("2000-01-01", periods=2)
result1, result2 = (Index(y).day for y in cartesian_product([x, x]))
expected1 = Index([1, 1, 2, 2])
expected2 = Index([1, 2, 1, 2])
tm.assert_index_equal(result1, expected1)
tm.assert_index_equal(result2, expected2)
Reported by Pylint.
Line: 34
Column: 18
def test_tzaware_retained(self):
x = date_range("2000-01-01", periods=2, tz="US/Pacific")
y = np.array([3, 4])
result1, result2 = cartesian_product([x, y])
expected = x.repeat(2)
tm.assert_index_equal(result1, expected)
def test_tzaware_retained_categorical(self):
Reported by Pylint.
Line: 42
Column: 18
def test_tzaware_retained_categorical(self):
x = date_range("2000-01-01", periods=2, tz="US/Pacific").astype("category")
y = np.array([3, 4])
result1, result2 = cartesian_product([x, y])
expected = x.repeat(2)
tm.assert_index_equal(result1, expected)
def test_empty(self):
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Index,
date_range,
)
import pandas._testing as tm
from pandas.core.reshape.util import cartesian_product
Reported by Pylint.
Line: 12
Column: 1
from pandas.core.reshape.util import cartesian_product
class TestCartesianProduct:
def test_simple(self):
x, y = list("ABC"), [1, 22]
result1, result2 = cartesian_product([x, y])
expected1 = np.array(["A", "A", "B", "B", "C", "C"])
expected2 = np.array([1, 22, 1, 22, 1, 22])
Reported by Pylint.
Line: 13
Column: 5
class TestCartesianProduct:
def test_simple(self):
x, y = list("ABC"), [1, 22]
result1, result2 = cartesian_product([x, y])
expected1 = np.array(["A", "A", "B", "B", "C", "C"])
expected2 = np.array([1, 22, 1, 22, 1, 22])
tm.assert_numpy_array_equal(result1, expected1)
Reported by Pylint.
Line: 13
Column: 5
class TestCartesianProduct:
def test_simple(self):
x, y = list("ABC"), [1, 22]
result1, result2 = cartesian_product([x, y])
expected1 = np.array(["A", "A", "B", "B", "C", "C"])
expected2 = np.array([1, 22, 1, 22, 1, 22])
tm.assert_numpy_array_equal(result1, expected1)
Reported by Pylint.
Line: 14
Column: 12
class TestCartesianProduct:
def test_simple(self):
x, y = list("ABC"), [1, 22]
result1, result2 = cartesian_product([x, y])
expected1 = np.array(["A", "A", "B", "B", "C", "C"])
expected2 = np.array([1, 22, 1, 22, 1, 22])
tm.assert_numpy_array_equal(result1, expected1)
tm.assert_numpy_array_equal(result2, expected2)
Reported by Pylint.
Line: 14
Column: 9
class TestCartesianProduct:
def test_simple(self):
x, y = list("ABC"), [1, 22]
result1, result2 = cartesian_product([x, y])
expected1 = np.array(["A", "A", "B", "B", "C", "C"])
expected2 = np.array([1, 22, 1, 22, 1, 22])
tm.assert_numpy_array_equal(result1, expected1)
tm.assert_numpy_array_equal(result2, expected2)
Reported by Pylint.
pandas/tests/extension/base/casting.py
33 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas.core.internals import ObjectBlock
from pandas.tests.extension.base.base import BaseExtensionTests
Reported by Pylint.
Line: 18
Column: 20
ser = pd.Series(all_data, name="A")
result = ser.astype(object)
assert result.dtype == np.dtype(object)
if hasattr(result._mgr, "blocks"):
assert isinstance(result._mgr.blocks[0], ObjectBlock)
assert isinstance(result._mgr.array, np.ndarray)
assert result._mgr.array.dtype == np.dtype(object)
def test_astype_object_frame(self, all_data):
Reported by Pylint.
Line: 19
Column: 31
result = ser.astype(object)
assert result.dtype == np.dtype(object)
if hasattr(result._mgr, "blocks"):
assert isinstance(result._mgr.blocks[0], ObjectBlock)
assert isinstance(result._mgr.array, np.ndarray)
assert result._mgr.array.dtype == np.dtype(object)
def test_astype_object_frame(self, all_data):
df = pd.DataFrame({"A": all_data})
Reported by Pylint.
Line: 20
Column: 27
assert result.dtype == np.dtype(object)
if hasattr(result._mgr, "blocks"):
assert isinstance(result._mgr.blocks[0], ObjectBlock)
assert isinstance(result._mgr.array, np.ndarray)
assert result._mgr.array.dtype == np.dtype(object)
def test_astype_object_frame(self, all_data):
df = pd.DataFrame({"A": all_data})
Reported by Pylint.
Line: 21
Column: 16
if hasattr(result._mgr, "blocks"):
assert isinstance(result._mgr.blocks[0], ObjectBlock)
assert isinstance(result._mgr.array, np.ndarray)
assert result._mgr.array.dtype == np.dtype(object)
def test_astype_object_frame(self, all_data):
df = pd.DataFrame({"A": all_data})
result = df.astype(object)
Reported by Pylint.
Line: 27
Column: 20
df = pd.DataFrame({"A": all_data})
result = df.astype(object)
if hasattr(result._mgr, "blocks"):
blk = result._data.blocks[0]
assert isinstance(blk, ObjectBlock), type(blk)
assert isinstance(result._mgr.arrays[0], np.ndarray)
assert result._mgr.arrays[0].dtype == np.dtype(object)
Reported by Pylint.
Line: 28
Column: 19
result = df.astype(object)
if hasattr(result._mgr, "blocks"):
blk = result._data.blocks[0]
assert isinstance(blk, ObjectBlock), type(blk)
assert isinstance(result._mgr.arrays[0], np.ndarray)
assert result._mgr.arrays[0].dtype == np.dtype(object)
# FIXME: these currently fail; dont leave commented-out
Reported by Pylint.
Line: 30
Column: 27
if hasattr(result._mgr, "blocks"):
blk = result._data.blocks[0]
assert isinstance(blk, ObjectBlock), type(blk)
assert isinstance(result._mgr.arrays[0], np.ndarray)
assert result._mgr.arrays[0].dtype == np.dtype(object)
# FIXME: these currently fail; dont leave commented-out
# check that we can compare the dtypes
# cmp = result.dtypes.equals(df.dtypes)
Reported by Pylint.
Line: 31
Column: 16
blk = result._data.blocks[0]
assert isinstance(blk, ObjectBlock), type(blk)
assert isinstance(result._mgr.arrays[0], np.ndarray)
assert result._mgr.arrays[0].dtype == np.dtype(object)
# FIXME: these currently fail; dont leave commented-out
# check that we can compare the dtypes
# cmp = result.dtypes.equals(df.dtypes)
# assert not cmp.any()
Reported by Pylint.
Line: 33
Column: 3
assert isinstance(result._mgr.arrays[0], np.ndarray)
assert result._mgr.arrays[0].dtype == np.dtype(object)
# FIXME: these currently fail; dont leave commented-out
# check that we can compare the dtypes
# cmp = result.dtypes.equals(df.dtypes)
# assert not cmp.any()
def test_tolist(self, data):
Reported by Pylint.