The following issues were found
pandas/tests/arrays/string_/test_string.py
131 issues
Line: 6
Column: 1
Tests for the str accessors are in pandas/tests/strings/test_string_array.py
"""
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas.core.dtypes.common import is_dtype_equal
Reported by Pylint.
Line: 295
Column: 9
result = cls._from_sequence(nan_arr, copy=copy)
if cls is ArrowStringArray:
import pyarrow as pa
expected = cls(pa.array(na_arr, type=pa.string(), from_pandas=True))
else:
expected = cls(na_arr)
Reported by Pylint.
Line: 419
Column: 5
@td.skip_if_no("pyarrow")
def test_arrow_array(dtype):
# protocol added in 0.15.0
import pyarrow as pa
data = pd.array(["a", "b", "c"], dtype=dtype)
arr = pa.array(data)
expected = pa.array(list(data), type=pa.string(), from_pandas=True)
if dtype.storage == "pyarrow":
Reported by Pylint.
Line: 433
Column: 5
@td.skip_if_no("pyarrow")
def test_arrow_roundtrip(dtype, string_storage2):
# roundtrip possible from arrow 1.0.0
import pyarrow as pa
data = pd.array(["a", "b", None], dtype=dtype)
df = pd.DataFrame({"a": data})
table = pa.table(df)
assert table.field("a").type == "string"
Reported by Pylint.
Line: 451
Column: 5
@td.skip_if_no("pyarrow")
def test_arrow_load_from_zero_chunks(dtype, string_storage2):
# GH-41040
import pyarrow as pa
data = pd.array([], dtype=dtype)
df = pd.DataFrame({"a": data})
table = pa.table(df)
assert table.field("a").type == "string"
Reported by Pylint.
Line: 23
Column: 9
@pytest.fixture
def cls(dtype):
return dtype.construct_array_type()
def test_repr(dtype):
df = pd.DataFrame({"A": pd.array(["a", pd.NA, "b"], dtype=dtype)})
Reported by Pylint.
Line: 27
Column: 15
return dtype.construct_array_type()
def test_repr(dtype):
df = pd.DataFrame({"A": pd.array(["a", pd.NA, "b"], dtype=dtype)})
expected = " A\n0 a\n1 <NA>\n2 b"
assert repr(df) == expected
expected = "0 a\n1 <NA>\n2 b\nName: A, dtype: string"
Reported by Pylint.
Line: 40
Column: 22
assert repr(df.A.array) == expected
def test_none_to_nan(cls):
a = cls._from_sequence(["a", None, "b"])
assert a[1] is not None
assert a[1] is pd.NA
Reported by Pylint.
Line: 41
Column: 9
def test_none_to_nan(cls):
a = cls._from_sequence(["a", None, "b"])
assert a[1] is not None
assert a[1] is pd.NA
def test_setitem_validates(cls):
Reported by Pylint.
Line: 46
Column: 28
assert a[1] is pd.NA
def test_setitem_validates(cls):
arr = cls._from_sequence(["a", "b"])
if cls is pd.arrays.StringArray:
msg = "Cannot set non-string value '10' into a StringArray."
else:
Reported by Pylint.
pandas/tests/reshape/test_crosstab.py
130 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas.core.dtypes.common import is_categorical_dtype
from pandas import (
CategoricalIndex,
DataFrame,
Index,
Reported by Pylint.
Line: 799
Column: 9
@pytest.mark.parametrize("b_dtype", ["category", "int64"])
def test_categoricals(a_dtype, b_dtype):
# https://github.com/pandas-dev/pandas/issues/37465
g = np.random.RandomState(25982704)
a = Series(g.randint(0, 3, size=100)).astype(a_dtype)
b = Series(g.randint(0, 2, size=100)).astype(b_dtype)
result = crosstab(a, b, margins=True, dropna=False)
columns = Index([0, 1, "All"], dtype="object", name="col_0")
index = Index([0, 1, 2, "All"], dtype="object", name="row_0")
Reported by Pylint.
Line: 18
Column: 28
class TestCrosstab:
def setup_method(self, method):
df = DataFrame(
{
"A": [
"foo",
"foo",
Reported by Pylint.
Line: 66
Column: 9
}
)
self.df = df.append(df, ignore_index=True)
def test_crosstab_single(self):
df = self.df
result = crosstab(df["A"], df["C"])
expected = df.groupby(["A", "C"]).size().unstack()
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas.core.dtypes.common import is_categorical_dtype
from pandas import (
CategoricalIndex,
DataFrame,
Index,
Reported by Pylint.
Line: 17
Column: 1
import pandas._testing as tm
class TestCrosstab:
def setup_method(self, method):
df = DataFrame(
{
"A": [
"foo",
Reported by Pylint.
Line: 17
Column: 1
import pandas._testing as tm
class TestCrosstab:
def setup_method(self, method):
df = DataFrame(
{
"A": [
"foo",
Reported by Pylint.
Line: 18
Column: 5
class TestCrosstab:
def setup_method(self, method):
df = DataFrame(
{
"A": [
"foo",
"foo",
Reported by Pylint.
Line: 19
Column: 9
class TestCrosstab:
def setup_method(self, method):
df = DataFrame(
{
"A": [
"foo",
"foo",
"foo",
Reported by Pylint.
Line: 66
Column: 9
}
)
self.df = df.append(df, ignore_index=True)
def test_crosstab_single(self):
df = self.df
result = crosstab(df["A"], df["C"])
expected = df.groupby(["A", "C"]).size().unstack()
Reported by Pylint.
pandas/tests/window/test_rolling.py
130 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
from pandas.compat import (
is_platform_arm,
is_platform_mac,
)
Reported by Pylint.
Line: 628
Column: 11
date_today = datetime.now()
days = date_range(date_today, date_today + timedelta(365), freq="D")
npr = np.random.RandomState(seed=421)
data = npr.randint(1, high=100, size=len(days))
df = DataFrame({"DateCol": days, "metric": data})
df.set_index("DateCol", inplace=True)
Reported by Pylint.
Line: 1274
Column: 20
start = np.empty(num_values, dtype=np.int64)
end = np.empty(num_values, dtype=np.int64)
for i in range(num_values):
if self.use_expanding[i]:
start[i] = 0
end[i] = i + 1
else:
start[i] = i
end[i] = i + self.window_size
Reported by Pylint.
Line: 35
Column: 5
def test_doc_string():
df = DataFrame({"B": [0, 1, 2, np.nan, 4]})
df
df.rolling(2).sum()
df.rolling(2, min_periods=1).sum()
def test_constructor(frame_or_series):
Reported by Pylint.
Line: 473
Column: 12
def test_rolling_axis_sum(axis_frame):
# see gh-23372.
df = DataFrame(np.ones((10, 20)))
axis = df._get_axis_number(axis_frame)
if axis == 0:
expected = DataFrame({i: [np.nan] * 2 + [3.0] * 8 for i in range(20)})
else:
# axis == 1
Reported by Pylint.
Line: 489
Column: 12
# see gh-26055
df = DataFrame({"x": range(3), "y": range(3)})
axis = df._get_axis_number(axis_frame)
if axis in [0, "index"]:
expected = DataFrame({"x": [1.0, 2.0, 2.0], "y": [1.0, 2.0, 2.0]})
else:
expected = DataFrame({"x": [1.0, 1.0, 1.0], "y": [2.0, 2.0, 2.0]})
Reported by Pylint.
Line: 639
Column: 13
].agg("max")
index = days.rename("DateCol")
index = index._with_freq(None)
expected = Series(expected_data, index=index, name="metric")
tm.assert_series_equal(result, expected)
def test_min_periods1():
Reported by Pylint.
Line: 1270
Column: 9
df = DataFrame({"values": np.arange(len(use_expanding)) ** 2})
class CustomIndexer(BaseIndexer):
def get_window_bounds(self, num_values, min_periods, center, closed):
start = np.empty(num_values, dtype=np.int64)
end = np.empty(num_values, dtype=np.int64)
for i in range(num_values):
if self.use_expanding[i]:
start[i] = 0
Reported by Pylint.
Line: 1361
Column: 52
@pytest.mark.parametrize("window", [1, "1d"])
def test_rolling_descending_date_order_with_offset(window, frame_or_series):
# GH#40002
idx = date_range(start="2020-01-01", end="2020-01-03", freq="1d")
obj = frame_or_series(range(1, 4), index=idx)
result = obj.rolling("1d", closed="left").sum()
expected = frame_or_series([np.nan, 1, 2], index=idx)
Reported by Pylint.
Line: 1
Column: 1
from datetime import (
datetime,
timedelta,
)
import numpy as np
import pytest
from pandas.compat import (
Reported by Pylint.
pandas/core/resample.py
130 issues
Line: 16
Column: 1
import numpy as np
from pandas._libs import lib
from pandas._libs.tslibs import (
BaseOffset,
IncompatibleFrequency,
NaT,
Period,
Reported by Pylint.
Line: 380
Column: 16
2018-01-01 01:00:00 NaN
Freq: H, dtype: float64
"""
return self._selected_obj.groupby(self.groupby).transform(arg, *args, **kwargs)
def _downsample(self, f):
raise AbstractMethodError(self)
def _upsample(self, f, limit=None, fill_value=None):
Reported by Pylint.
Line: 471
Column: 17
# error: Cannot determine type of 'loffset'
needs_offset = (
isinstance(
self.loffset, # type: ignore[has-type]
(DateOffset, timedelta, np.timedelta64),
)
and isinstance(result.index, DatetimeIndex)
and len(result.index) > 0
)
Reported by Pylint.
Line: 480
Column: 43
if needs_offset:
# error: Cannot determine type of 'loffset'
result.index = result.index + self.loffset # type: ignore[has-type]
self.loffset = None
return result
def _get_resampler_for_grouping(self, groupby):
Reported by Pylint.
Line: 918
Column: 16
"""
nv.validate_resampler_func("std", args, kwargs)
# error: Unexpected keyword argument "ddof" for "_downsample"
return self._downsample("std", ddof=ddof) # type: ignore[call-arg]
def var(self, ddof=1, *args, **kwargs):
"""
Compute variance of groups, excluding missing values.
Reported by Pylint.
Line: 936
Column: 16
"""
nv.validate_resampler_func("var", args, kwargs)
# error: Unexpected keyword argument "ddof" for "_downsample"
return self._downsample("var", ddof=ddof) # type: ignore[call-arg]
@doc(GroupBy.size)
def size(self):
result = self._downsample("size")
if not len(self.ax):
Reported by Pylint.
Line: 944
Column: 16
if not len(self.ax):
from pandas import Series
if self._selected_obj.ndim == 1:
name = self._selected_obj.name
else:
name = None
result = Series([], index=result.index, dtype="int64", name=name)
return result
Reported by Pylint.
Line: 945
Column: 24
from pandas import Series
if self._selected_obj.ndim == 1:
name = self._selected_obj.name
else:
name = None
result = Series([], index=result.index, dtype="int64", name=name)
return result
Reported by Pylint.
Line: 955
Column: 16
def count(self):
result = self._downsample("count")
if not len(self.ax):
if self._selected_obj.ndim == 1:
result = type(self._selected_obj)(
[], index=result.index, dtype="int64", name=self._selected_obj.name
)
else:
from pandas import DataFrame
Reported by Pylint.
Line: 957
Column: 65
if not len(self.ax):
if self._selected_obj.ndim == 1:
result = type(self._selected_obj)(
[], index=result.index, dtype="int64", name=self._selected_obj.name
)
else:
from pandas import DataFrame
result = DataFrame(
Reported by Pylint.
pandas/tests/reshape/concat/test_concat.py
130 issues
Line: 9
Column: 1
from warnings import catch_warnings
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Index,
Reported by Pylint.
Line: 52
Column: 20
# These are actual copies.
result = concat([df, df2, df3], axis=1, copy=True)
for arr in result._mgr.arrays:
assert arr.base is None
# These are the same.
result = concat([df, df2, df3], axis=1, copy=False)
Reported by Pylint.
Line: 58
Column: 20
# These are the same.
result = concat([df, df2, df3], axis=1, copy=False)
for arr in result._mgr.arrays:
if arr.dtype.kind == "f":
assert arr.base is df._mgr.arrays[0].base
elif arr.dtype.kind in ["i", "u"]:
assert arr.base is df2._mgr.arrays[0].base
elif arr.dtype == object:
Reported by Pylint.
Line: 60
Column: 36
for arr in result._mgr.arrays:
if arr.dtype.kind == "f":
assert arr.base is df._mgr.arrays[0].base
elif arr.dtype.kind in ["i", "u"]:
assert arr.base is df2._mgr.arrays[0].base
elif arr.dtype == object:
if using_array_manager:
# we get the same array object, which has no base
Reported by Pylint.
Line: 62
Column: 36
if arr.dtype.kind == "f":
assert arr.base is df._mgr.arrays[0].base
elif arr.dtype.kind in ["i", "u"]:
assert arr.base is df2._mgr.arrays[0].base
elif arr.dtype == object:
if using_array_manager:
# we get the same array object, which has no base
assert arr is df3._mgr.arrays[0]
else:
Reported by Pylint.
Line: 66
Column: 35
elif arr.dtype == object:
if using_array_manager:
# we get the same array object, which has no base
assert arr is df3._mgr.arrays[0]
else:
assert arr.base is not None
# Float block was consolidated.
df4 = DataFrame(np.random.randn(4, 1))
Reported by Pylint.
Line: 73
Column: 20
# Float block was consolidated.
df4 = DataFrame(np.random.randn(4, 1))
result = concat([df, df2, df3, df4], axis=1, copy=False)
for arr in result._mgr.arrays:
if arr.dtype.kind == "f":
if using_array_manager:
# this is a view on some array in either df or df4
assert any(
np.shares_memory(arr, other)
Reported by Pylint.
Line: 79
Column: 55
# this is a view on some array in either df or df4
assert any(
np.shares_memory(arr, other)
for other in df._mgr.arrays + df4._mgr.arrays
)
else:
# the block was consolidated, so we got a copy anyway
assert arr.base is None
elif arr.dtype.kind in ["i", "u"]:
Reported by Pylint.
Line: 79
Column: 38
# this is a view on some array in either df or df4
assert any(
np.shares_memory(arr, other)
for other in df._mgr.arrays + df4._mgr.arrays
)
else:
# the block was consolidated, so we got a copy anyway
assert arr.base is None
elif arr.dtype.kind in ["i", "u"]:
Reported by Pylint.
Line: 85
Column: 36
# the block was consolidated, so we got a copy anyway
assert arr.base is None
elif arr.dtype.kind in ["i", "u"]:
assert arr.base is df2._mgr.arrays[0].base
elif arr.dtype == object:
# this is a view on df3
assert any(np.shares_memory(arr, other) for other in df3._mgr.arrays)
def test_concat_with_group_keys(self):
Reported by Pylint.
pandas/tests/generic/test_generic.py
129 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
from pandas.core.dtypes.common import is_scalar
from pandas import (
DataFrame,
Reported by Pylint.
Line: 24
Column: 16
class Generic:
@property
def _ndim(self):
return self._typ._AXIS_LEN
def _axes(self):
"""return the axes for my object typ"""
return self._typ._AXIS_ORDERS
Reported by Pylint.
Line: 28
Column: 16
def _axes(self):
"""return the axes for my object typ"""
return self._typ._AXIS_ORDERS
def _construct(self, shape, value=None, dtype=None, **kwargs):
"""
construct an object for the given shape
if value is specified use that if its a scalar
Reported by Pylint.
Line: 45
Column: 32
dtype = np.float64
# remove the info axis
kwargs.pop(self._typ._info_axis_name, None)
else:
arr = np.empty(shape, dtype=dtype)
arr.fill(value)
else:
fshape = np.prod(shape)
Reported by Pylint.
Line: 59
Column: 16
arr = np.repeat(arr, new_shape).reshape(shape)
else:
arr = np.random.randn(*shape)
return self._typ(arr, dtype=dtype, **kwargs)
def _compare(self, result, expected):
self._comparator(result, expected)
def test_rename(self):
Reported by Pylint.
Line: 62
Column: 9
return self._typ(arr, dtype=dtype, **kwargs)
def _compare(self, result, expected):
self._comparator(result, expected)
def test_rename(self):
# single axis
idx = list("ABCD")
Reported by Pylint.
Line: 92
Column: 13
n = 4
kwargs = {
self._typ._get_axis_name(i): list(range(n)) for i in range(self._ndim)
}
# get the numeric data
o = self._construct(n, **kwargs)
result = o._get_numeric_data()
Reported by Pylint.
Line: 122
Column: 39
# GH 4633
# look at the boolean/nonzero behavior for objects
obj = self._construct(shape=4)
msg = f"The truth value of a {self._typ.__name__} is ambiguous"
with pytest.raises(ValueError, match=msg):
bool(obj == 0)
with pytest.raises(ValueError, match=msg):
bool(obj == 1)
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 188
Column: 14
return self._construct(shape=3, value=1, dtype=dtype)
msg = (
"compound dtypes are not implemented "
f"in the {self._typ.__name__} constructor"
)
with pytest.raises(NotImplementedError, match=msg):
f([("A", "datetime64[h]"), ("B", "str"), ("C", "int32")])
Reported by Pylint.
Line: 24
Column: 16
class Generic:
@property
def _ndim(self):
return self._typ._AXIS_LEN
def _axes(self):
"""return the axes for my object typ"""
return self._typ._AXIS_ORDERS
Reported by Pylint.
pandas/tests/plotting/test_boxplot_method.py
129 issues
Line: 7
Column: 1
import string
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Reported by Pylint.
Line: 64
Column: 19
# When ax is supplied and required number of axes is 1,
# passed ax should be used:
fig, ax = self.plt.subplots()
axes = df.boxplot("Col1", by="X", ax=ax)
ax_axes = ax.axes
assert ax_axes is axes
fig, ax = self.plt.subplots()
Reported by Pylint.
Line: 69
Column: 19
ax_axes = ax.axes
assert ax_axes is axes
fig, ax = self.plt.subplots()
axes = df.groupby("Y").boxplot(ax=ax, return_type="axes")
ax_axes = ax.axes
assert ax_axes is axes["A"]
# Multiple columns with an ax argument should use same figure
Reported by Pylint.
Line: 75
Column: 19
assert ax_axes is axes["A"]
# Multiple columns with an ax argument should use same figure
fig, ax = self.plt.subplots()
with tm.assert_produces_warning(UserWarning):
axes = df.boxplot(
column=["Col1", "Col2"], by="X", ax=ax, return_type="axes"
)
assert axes["Col1"].get_figure() is fig
Reported by Pylint.
Line: 84
Column: 19
# When by is None, check that all relevant lines are present in the
# dict
fig, ax = self.plt.subplots()
d = df.boxplot(ax=ax, return_type="dict")
lines = list(itertools.chain.from_iterable(d.values()))
assert len(ax.get_lines()) == len(lines)
def test_boxplot_return_type_none(self):
Reported by Pylint.
Line: 92
Column: 35
def test_boxplot_return_type_none(self):
# GH 12216; return_type=None & by=None -> axes
result = self.hist_df.boxplot()
assert isinstance(result, self.plt.Axes)
def test_boxplot_return_type_legacy(self):
# API change in https://github.com/pandas-dev/pandas/pull/7096
import matplotlib as mpl # noqa
Reported by Pylint.
Line: 300
Column: 20
gb = df.groupby("gender")
res = gb.plot()
assert len(self.plt.get_fignums()) == 2
assert len(res) == 2
tm.close()
res = gb.boxplot(return_type="axes")
assert len(self.plt.get_fignums()) == 1
Reported by Pylint.
Line: 305
Column: 20
tm.close()
res = gb.boxplot(return_type="axes")
assert len(self.plt.get_fignums()) == 1
assert len(res) == 2
tm.close()
# now works with GH 5610 as gender is excluded
res = df.groupby("gender").hist()
Reported by Pylint.
Line: 371
Column: 32
box = _check_plot_works(
df.groupby("gender").boxplot, column="height", return_type="dict"
)
self._check_axes_shape(self.plt.gcf().axes, axes_num=2, layout=(1, 2))
with tm.assert_produces_warning(UserWarning):
box = _check_plot_works(
df.groupby("category").boxplot, column="height", return_type="dict"
)
Reported by Pylint.
Line: 377
Column: 32
box = _check_plot_works(
df.groupby("category").boxplot, column="height", return_type="dict"
)
self._check_axes_shape(self.plt.gcf().axes, axes_num=4, layout=(2, 2))
# GH 6769
with tm.assert_produces_warning(UserWarning):
box = _check_plot_works(
df.groupby("classroom").boxplot, column="height", return_type="dict"
Reported by Pylint.
pandas/tests/frame/test_block_internals.py
127 issues
Line: 9
Column: 1
import itertools
import numpy as np
import pytest
from pandas.errors import PerformanceWarning
import pandas.util._test_decorators as td
import pandas as pd
Reported by Pylint.
Line: 54
Column: 16
assert df["B"]._values.freq is None
# check that the DatetimeIndex was not altered in place
assert dti.freq == "D"
assert dti[1] == ts
def test_cast_internals(self, float_frame):
casted = DataFrame(float_frame._mgr, dtype=int)
expected = DataFrame(float_frame._series, dtype=int)
Reported by Pylint.
Line: 54
Column: 16
assert df["B"]._values.freq is None
# check that the DatetimeIndex was not altered in place
assert dti.freq == "D"
assert dti[1] == ts
def test_cast_internals(self, float_frame):
casted = DataFrame(float_frame._mgr, dtype=int)
expected = DataFrame(float_frame._series, dtype=int)
Reported by Pylint.
Line: 34
Column: 3
# structure
# TODO(ArrayManager) check which of those tests need to be rewritten to test the
# equivalent for ArrayManager
pytestmark = td.skip_array_manager_invalid_test
class TestDataFrameBlockInternals:
Reported by Pylint.
Line: 48
Column: 16
ts = dti[1]
df = DataFrame({"B": dti})
assert df["B"]._values.freq is None
df.iloc[1, 0] = pd.NaT
assert df["B"]._values.freq is None
# check that the DatetimeIndex was not altered in place
Reported by Pylint.
Line: 51
Column: 16
assert df["B"]._values.freq is None
df.iloc[1, 0] = pd.NaT
assert df["B"]._values.freq is None
# check that the DatetimeIndex was not altered in place
assert dti.freq == "D"
assert dti[1] == ts
Reported by Pylint.
Line: 58
Column: 28
assert dti[1] == ts
def test_cast_internals(self, float_frame):
casted = DataFrame(float_frame._mgr, dtype=int)
expected = DataFrame(float_frame._series, dtype=int)
tm.assert_frame_equal(casted, expected)
casted = DataFrame(float_frame._mgr, dtype=np.int32)
expected = DataFrame(float_frame._series, dtype=np.int32)
Reported by Pylint.
Line: 59
Column: 30
def test_cast_internals(self, float_frame):
casted = DataFrame(float_frame._mgr, dtype=int)
expected = DataFrame(float_frame._series, dtype=int)
tm.assert_frame_equal(casted, expected)
casted = DataFrame(float_frame._mgr, dtype=np.int32)
expected = DataFrame(float_frame._series, dtype=np.int32)
tm.assert_frame_equal(casted, expected)
Reported by Pylint.
Line: 62
Column: 28
expected = DataFrame(float_frame._series, dtype=int)
tm.assert_frame_equal(casted, expected)
casted = DataFrame(float_frame._mgr, dtype=np.int32)
expected = DataFrame(float_frame._series, dtype=np.int32)
tm.assert_frame_equal(casted, expected)
def test_consolidate(self, float_frame):
float_frame["E"] = 7.0
Reported by Pylint.
Line: 63
Column: 30
tm.assert_frame_equal(casted, expected)
casted = DataFrame(float_frame._mgr, dtype=np.int32)
expected = DataFrame(float_frame._series, dtype=np.int32)
tm.assert_frame_equal(casted, expected)
def test_consolidate(self, float_frame):
float_frame["E"] = 7.0
consolidated = float_frame._consolidate()
Reported by Pylint.
pandas/io/sql.py
126 issues
Line: 27
Column: 1
import numpy as np
import pandas._libs.lib as lib
from pandas._typing import DtypeArg
from pandas.compat._optional import import_optional_dependency
from pandas.errors import AbstractMethodError
from pandas.core.dtypes.common import (
Reported by Pylint.
Line: 27
Column: 1
import numpy as np
import pandas._libs.lib as lib
from pandas._typing import DtypeArg
from pandas.compat._optional import import_optional_dependency
from pandas.errors import AbstractMethodError
from pandas.core.dtypes.common import (
Reported by Pylint.
Line: 1296
Column: 28
# https://stackoverflow.com/a/67358288/6067848
msg = r"""(\(1054, "Unknown column 'inf(e0)?' in 'field list'"\))(?#
)|inf can not be used with MySQL"""
err_text = str(err.orig)
if re.search(msg, err_text):
raise ValueError("inf cannot be used with MySQL") from err
else:
raise err
Reported by Pylint.
Line: 91
Column: 35
def _handle_date_column(
col, utc: bool | None = None, format: str | dict[str, Any] | None = None
):
if isinstance(format, dict):
# GH35185 Allow custom error values in parse_dates argument of
# read_sql like functions.
# Format can take on custom to_datetime argument values such as
Reported by Pylint.
Line: 574
Column: 12
try:
_is_table_name = pandas_sql.has_table(sql)
except Exception:
# using generic exception to catch errors from sql drivers (GH24988)
_is_table_name = False
if _is_table_name:
pandas_sql.meta.reflect(bind=pandas_sql.connectable, only=[sql])
Reported by Pylint.
Line: 753
Column: 3
pass them between functions all the time.
"""
# TODO: support for multiIndex
def __init__(
self,
name: str,
pandas_sql_engine,
Reported by Pylint.
Line: 864
Column: 20
data_list = [None] * ncols
for i, (_, ser) in enumerate(temp.items()):
vals = ser._values
if vals.dtype.kind == "M":
d = vals.to_pydatetime()
elif vals.dtype.kind == "m":
# store as integers, see GH#6921, GH#7076
d = vals.view("i8").astype(object)
Reported by Pylint.
Line: 875
Column: 16
assert isinstance(d, np.ndarray), type(d)
if ser._can_hold_na:
# Note: this will miss timedeltas since they are converted to int
mask = isna(d)
d[mask] = None
# error: No overload variant of "__setitem__" of "list" matches
Reported by Pylint.
Line: 1029
Column: 41
column_names_and_types = []
if self.index is not None:
for i, idx_label in enumerate(self.index):
idx_type = dtype_mapper(self.frame.index._get_level_values(i))
column_names_and_types.append((str(idx_label), idx_type, True))
column_names_and_types += [
(str(self.frame.columns[i]), dtype_mapper(self.frame.iloc[:, i]), False)
for i in range(len(self.frame.columns))
Reported by Pylint.
Line: 1204
Column: 3
if isinstance(sqltype, Float):
return float
elif isinstance(sqltype, Integer):
# TODO: Refine integer size.
return np.dtype("int64")
elif isinstance(sqltype, TIMESTAMP):
# we have a timezone capable type
if not sqltype.timezone:
return datetime
Reported by Pylint.
asv_bench/benchmarks/reshape.py
126 issues
Line: 6
Column: 1
import numpy as np
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
date_range,
melt,
Reported by Pylint.
Line: 7
Column: 1
import numpy as np
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
date_range,
melt,
wide_to_long,
Reported by Pylint.
Line: 14
Column: 1
melt,
wide_to_long,
)
from pandas.api.types import CategoricalDtype
class Melt:
def setup(self):
self.df = DataFrame(np.random.randn(10000, 3), columns=["A", "B", "C"])
Reported by Pylint.
Line: 319
Column: 1
self.series.explode()
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 19
Column: 9
class Melt:
def setup(self):
self.df = DataFrame(np.random.randn(10000, 3), columns=["A", "B", "C"])
self.df["id1"] = np.random.randint(0, 10, 10000)
self.df["id2"] = np.random.randint(100, 1000, 10000)
def time_melt_dataframe(self):
melt(self.df, id_vars=["id1", "id2"])
Reported by Pylint.
Line: 36
Column: 9
"variable": np.arange(50).repeat(N),
"date": np.tile(index.values, 50),
}
self.df = DataFrame(data)
def time_reshape_pivot_time_series(self):
self.df.pivot("date", "variable", "value")
Reported by Pylint.
Line: 46
Column: 9
def setup(self):
arrays = [np.arange(100).repeat(100), np.roll(np.tile(np.arange(100), 100), 25)]
index = MultiIndex.from_arrays(arrays)
self.df = DataFrame(np.random.randn(10000, 4), index=index)
self.udf = self.df.unstack(1)
def time_stack(self):
self.udf.stack()
Reported by Pylint.
Line: 47
Column: 9
arrays = [np.arange(100).repeat(100), np.roll(np.tile(np.arange(100), 100), 25)]
index = MultiIndex.from_arrays(arrays)
self.df = DataFrame(np.random.randn(10000, 4), index=index)
self.udf = self.df.unstack(1)
def time_stack(self):
self.udf.stack()
def time_unstack(self):
Reported by Pylint.
Line: 74
Column: 9
df = ser.unstack("bar")
# roundtrips -> df.stack().equals(ser)
self.ser = ser
self.df = df
def time_stack(self, dtype):
self.df.stack()
Reported by Pylint.
Line: 75
Column: 9
# roundtrips -> df.stack().equals(ser)
self.ser = ser
self.df = df
def time_stack(self, dtype):
self.df.stack()
def time_unstack_fast(self, dtype):
Reported by Pylint.