The following issues were found
pandas/tests/series/test_subclass.py
29 issues
Line: 1
Column: 1
import numpy as np
import pandas as pd
import pandas._testing as tm
class TestSeriesSubclassing:
def test_indexing_sliced(self):
s = tm.SubclassedSeries([1, 2, 3, 4], index=list("abcd"))
Reported by Pylint.
Line: 7
Column: 1
import pandas._testing as tm
class TestSeriesSubclassing:
def test_indexing_sliced(self):
s = tm.SubclassedSeries([1, 2, 3, 4], index=list("abcd"))
res = s.loc[["a", "b"]]
exp = tm.SubclassedSeries([1, 2], index=list("ab"))
tm.assert_series_equal(res, exp)
Reported by Pylint.
Line: 8
Column: 5
class TestSeriesSubclassing:
def test_indexing_sliced(self):
s = tm.SubclassedSeries([1, 2, 3, 4], index=list("abcd"))
res = s.loc[["a", "b"]]
exp = tm.SubclassedSeries([1, 2], index=list("ab"))
tm.assert_series_equal(res, exp)
Reported by Pylint.
Line: 8
Column: 5
class TestSeriesSubclassing:
def test_indexing_sliced(self):
s = tm.SubclassedSeries([1, 2, 3, 4], index=list("abcd"))
res = s.loc[["a", "b"]]
exp = tm.SubclassedSeries([1, 2], index=list("ab"))
tm.assert_series_equal(res, exp)
Reported by Pylint.
Line: 9
Column: 9
class TestSeriesSubclassing:
def test_indexing_sliced(self):
s = tm.SubclassedSeries([1, 2, 3, 4], index=list("abcd"))
res = s.loc[["a", "b"]]
exp = tm.SubclassedSeries([1, 2], index=list("ab"))
tm.assert_series_equal(res, exp)
res = s.iloc[[2, 3]]
Reported by Pylint.
Line: 22
Column: 5
exp = tm.SubclassedSeries([1, 2], index=list("ab"))
tm.assert_series_equal(res, exp)
def test_to_frame(self):
s = tm.SubclassedSeries([1, 2, 3, 4], index=list("abcd"), name="xxx")
res = s.to_frame()
exp = tm.SubclassedDataFrame({"xxx": [1, 2, 3, 4]}, index=list("abcd"))
tm.assert_frame_equal(res, exp)
Reported by Pylint.
Line: 22
Column: 5
exp = tm.SubclassedSeries([1, 2], index=list("ab"))
tm.assert_series_equal(res, exp)
def test_to_frame(self):
s = tm.SubclassedSeries([1, 2, 3, 4], index=list("abcd"), name="xxx")
res = s.to_frame()
exp = tm.SubclassedDataFrame({"xxx": [1, 2, 3, 4]}, index=list("abcd"))
tm.assert_frame_equal(res, exp)
Reported by Pylint.
Line: 23
Column: 9
tm.assert_series_equal(res, exp)
def test_to_frame(self):
s = tm.SubclassedSeries([1, 2, 3, 4], index=list("abcd"), name="xxx")
res = s.to_frame()
exp = tm.SubclassedDataFrame({"xxx": [1, 2, 3, 4]}, index=list("abcd"))
tm.assert_frame_equal(res, exp)
def test_subclass_unstack(self):
Reported by Pylint.
Line: 28
Column: 5
exp = tm.SubclassedDataFrame({"xxx": [1, 2, 3, 4]}, index=list("abcd"))
tm.assert_frame_equal(res, exp)
def test_subclass_unstack(self):
# GH 15564
s = tm.SubclassedSeries([1, 2, 3, 4], index=[list("aabb"), list("xyxy")])
res = s.unstack()
exp = tm.SubclassedDataFrame({"x": [1, 3], "y": [2, 4]}, index=["a", "b"])
Reported by Pylint.
Line: 28
Column: 5
exp = tm.SubclassedDataFrame({"xxx": [1, 2, 3, 4]}, index=list("abcd"))
tm.assert_frame_equal(res, exp)
def test_subclass_unstack(self):
# GH 15564
s = tm.SubclassedSeries([1, 2, 3, 4], index=[list("aabb"), list("xyxy")])
res = s.unstack()
exp = tm.SubclassedDataFrame({"x": [1, 3], "y": [2, 4]}, index=["a", "b"])
Reported by Pylint.
pandas/core/util/hashing.py
29 issues
Line: 17
Column: 1
import numpy as np
from pandas._libs import lib
from pandas._libs.hashing import hash_object_array
from pandas._typing import ArrayLike
from pandas.core.dtypes.common import (
is_categorical_dtype,
Reported by Pylint.
Line: 18
Column: 1
import numpy as np
from pandas._libs import lib
from pandas._libs.hashing import hash_object_array
from pandas._typing import ArrayLike
from pandas.core.dtypes.common import (
is_categorical_dtype,
is_list_like,
Reported by Pylint.
Line: 18
Column: 1
import numpy as np
from pandas._libs import lib
from pandas._libs.hashing import hash_object_array
from pandas._typing import ArrayLike
from pandas.core.dtypes.common import (
is_categorical_dtype,
is_list_like,
Reported by Pylint.
Line: 73
Column: 12
out ^= a
out *= mult
mult += np.uint64(82520 + inverse_i + inverse_i)
assert i + 1 == num_items, "Fed in wrong num_items"
out += np.uint64(97531)
return out
def hash_pandas_object(
Reported by Pylint.
Line: 114
Column: 24
return Series(hash_tuples(obj, encoding, hash_key), dtype="uint64", copy=False)
elif isinstance(obj, ABCIndex):
h = hash_array(obj._values, encoding, hash_key, categorize).astype(
"uint64", copy=False
)
ser = Series(h, index=obj, dtype="uint64", copy=False)
elif isinstance(obj, ABCSeries):
Reported by Pylint.
Line: 120
Column: 24
ser = Series(h, index=obj, dtype="uint64", copy=False)
elif isinstance(obj, ABCSeries):
h = hash_array(obj._values, encoding, hash_key, categorize).astype(
"uint64", copy=False
)
if index:
index_iter = (
hash_pandas_object(
Reported by Pylint.
Line: 125
Column: 17
)
if index:
index_iter = (
hash_pandas_object(
obj.index,
index=False,
encoding=encoding,
hash_key=hash_key,
categorize=categorize,
Reported by Pylint.
Line: 141
Column: 24
elif isinstance(obj, ABCDataFrame):
hashes = (
hash_array(series._values, encoding, hash_key, categorize)
for _, series in obj.items()
)
num_items = len(obj.columns)
if index:
index_hash_generator = (
Reported by Pylint.
Line: 147
Column: 17
num_items = len(obj.columns)
if index:
index_hash_generator = (
hash_pandas_object(
obj.index,
index=False,
encoding=encoding,
hash_key=hash_key,
categorize=categorize,
Reported by Pylint.
Line: 232
Column: 25
ndarray[np.uint64] of hashed values, same size as len(c)
"""
# Convert ExtensionArrays to ndarrays
values = np.asarray(cat.categories._values)
hashed = hash_array(values, encoding, hash_key, categorize=False)
# we have uint64, as we don't directly support missing values
# we don't want to use take_nd which will coerce to float
# instead, directly construct the result with a
Reported by Pylint.
pandas/core/reshape/tile.py
29 issues
Line: 16
Column: 1
Timedelta,
Timestamp,
)
from pandas._libs.lib import infer_dtype
from pandas.core.dtypes.common import (
DT64NS_DTYPE,
ensure_platform_int,
is_bool_dtype,
Reported by Pylint.
Line: 16
Column: 1
Timedelta,
Timestamp,
)
from pandas._libs.lib import infer_dtype
from pandas.core.dtypes.common import (
DT64NS_DTYPE,
ensure_platform_int,
is_bool_dtype,
Reported by Pylint.
Line: 559
Column: 16
"""based on the dtype, return our labels"""
closed = "right" if right else "left"
formatter: Callable[[Any], Timestamp] | Callable[[Any], Timedelta]
if is_datetime64tz_dtype(dtype):
formatter = lambda x: Timestamp(x, tz=dtype.tz)
adjust = lambda x: x - Timedelta("1ns")
elif is_datetime64_dtype(dtype):
Reported by Pylint.
Line: 456
Column: 3
categories=labels if len(set(labels)) == len(labels) else None,
ordered=ordered,
)
# TODO: handle mismatch between categorical label order and pandas.cut order.
np.putmask(ids, na_mask, 0)
result = algos.take_nd(labels, ids - 1)
else:
result = ids - 1
Reported by Pylint.
Line: 607
Column: 15
datatype was a series
"""
if isinstance(original, ABCSeries):
fac = original._constructor(fac, index=original.index, name=original.name)
if not retbins:
return fac
bins = _convert_bin_to_datelike_type(bins, dtype)
Reported by Pylint.
Line: 47
Column: 1
import pandas.core.nanops as nanops
def cut(
x,
bins,
right: bool = True,
labels=None,
retbins: bool = False,
Reported by Pylint.
Line: 47
Column: 1
import pandas.core.nanops as nanops
def cut(
x,
bins,
right: bool = True,
labels=None,
retbins: bool = False,
Reported by Pylint.
Line: 47
Column: 1
import pandas.core.nanops as nanops
def cut(
x,
bins,
right: bool = True,
labels=None,
retbins: bool = False,
Reported by Pylint.
Line: 47
Column: 1
import pandas.core.nanops as nanops
def cut(
x,
bins,
right: bool = True,
labels=None,
retbins: bool = False,
Reported by Pylint.
Line: 245
Column: 13
raise ValueError("`bins` should be a positive integer.")
try: # for array-like
sz = x.size
except AttributeError:
x = np.asarray(x)
sz = x.size
if sz == 0:
Reported by Pylint.
pandas/tests/io/pytables/test_errors.py
29 issues
Line: 7
Column: 1
from warnings import catch_warnings
import numpy as np
import pytest
from pandas import (
CategoricalIndex,
DataFrame,
HDFStore,
Reported by Pylint.
Line: 110
Column: 17
"__init__() missing 1 required positional argument: 'where'"
)
with pytest.raises(TypeError, match=msg):
Term()
# more invalid
msg = re.escape(
"cannot process expression [df.index[3]], "
"[2000-01-06 00:00:00] is not a valid condition"
Reported by Pylint.
Line: 81
Column: 10
df["obj1"] = "foo"
df["obj2"] = "bar"
df["datetime1"] = datetime.date(2001, 1, 2)
df = df._consolidate()._convert(datetime=True)
with ensure_clean_store(setup_path) as store:
# this fails because we have a date in the object block......
msg = re.escape(
"""Cannot serialize the column [datetime1]
Reported by Pylint.
Line: 81
Column: 10
df["obj1"] = "foo"
df["obj2"] = "bar"
df["datetime1"] = datetime.date(2001, 1, 2)
df = df._consolidate()._convert(datetime=True)
with ensure_clean_store(setup_path) as store:
# this fails because we have a date in the object block......
msg = re.escape(
"""Cannot serialize the column [datetime1]
Reported by Pylint.
Line: 1
Column: 1
import datetime
from io import BytesIO
import re
from warnings import catch_warnings
import numpy as np
import pytest
from pandas import (
Reported by Pylint.
Line: 31
Column: 1
pytestmark = pytest.mark.single
def test_pass_spec_to_storer(setup_path):
df = tm.makeDataFrame()
with ensure_clean_store(setup_path) as store:
store.put("df", df)
Reported by Pylint.
Line: 33
Column: 5
def test_pass_spec_to_storer(setup_path):
df = tm.makeDataFrame()
with ensure_clean_store(setup_path) as store:
store.put("df", df)
msg = (
"cannot pass a column specification when reading a Fixed format "
Reported by Pylint.
Line: 51
Column: 1
store.select("df", where=[("columns=A")])
def test_table_index_incompatible_dtypes(setup_path):
df1 = DataFrame({"a": [1, 2, 3]})
df2 = DataFrame({"a": [4, 5, 6]}, index=date_range("1/1/2000", periods=3))
with ensure_clean_store(setup_path) as store:
store.put("frame", df1, format="table")
Reported by Pylint.
Line: 62
Column: 1
store.put("frame", df2, format="table", append=True)
def test_unimplemented_dtypes_table_columns(setup_path):
with ensure_clean_store(setup_path) as store:
dtypes = [("date", datetime.date(2001, 1, 2))]
Reported by Pylint.
Line: 69
Column: 13
dtypes = [("date", datetime.date(2001, 1, 2))]
# currently not supported dtypes ####
for n, f in dtypes:
df = tm.makeDataFrame()
df[n] = f
msg = re.escape(f"[{n}] is not implemented as a table column")
with pytest.raises(TypeError, match=msg):
store.append(f"df1_{n}", df)
Reported by Pylint.
pandas/tests/io/parser/test_header.py
29 issues
Line: 10
Column: 1
from io import StringIO
import numpy as np
import pytest
from pandas.errors import ParserError
from pandas import (
DataFrame,
Reported by Pylint.
Line: 22
Column: 1
import pandas._testing as tm
def test_read_with_bad_header(all_parsers):
parser = all_parsers
msg = r"but only \d+ lines in file"
with pytest.raises(ValueError, match=msg):
s = StringIO(",,")
Reported by Pylint.
Line: 27
Column: 9
msg = r"but only \d+ lines in file"
with pytest.raises(ValueError, match=msg):
s = StringIO(",,")
parser.read_csv(s, header=[10])
def test_negative_header(all_parsers):
# see gh-27779
Reported by Pylint.
Line: 31
Column: 1
parser.read_csv(s, header=[10])
def test_negative_header(all_parsers):
# see gh-27779
parser = all_parsers
data = """1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
Reported by Pylint.
Line: 47
Column: 1
@pytest.mark.parametrize("header", [([-1, 2, 4]), ([-5, 0])])
def test_negative_multi_index_header(all_parsers, header):
# see gh-27779
parser = all_parsers
data = """1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
Reported by Pylint.
Line: 61
Column: 1
@pytest.mark.parametrize("header", [True, False])
def test_bool_header_arg(all_parsers, header):
# see gh-6114
parser = all_parsers
data = """\
MyColumn
a
Reported by Pylint.
Line: 75
Column: 1
parser.read_csv(StringIO(data), header=header)
def test_no_header_prefix(all_parsers):
parser = all_parsers
data = """1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
"""
Reported by Pylint.
Line: 89
Column: 1
tm.assert_frame_equal(result, expected)
def test_header_with_index_col(all_parsers):
parser = all_parsers
data = """foo,1,2,3
bar,4,5,6
baz,7,8,9
"""
Reported by Pylint.
Line: 106
Column: 1
tm.assert_frame_equal(result, expected)
def test_header_not_first_line(all_parsers):
parser = all_parsers
data = """got,to,ignore,this,line
got,to,ignore,this,line
index,A,B,C,D
foo,2,3,4,5
Reported by Pylint.
Line: 126
Column: 1
tm.assert_frame_equal(result, expected)
def test_header_multi_index(all_parsers):
parser = all_parsers
expected = tm.makeCustomDataframe(5, 3, r_idx_nlevels=2, c_idx_nlevels=4)
data = """\
C0,,C_l0_g0,C_l0_g1,C_l0_g2
Reported by Pylint.
pandas/tests/util/test_assert_numpy_array_equal.py
29 issues
Line: 4
Column: 1
import copy
import numpy as np
import pytest
import pandas as pd
from pandas import Timestamp
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import copy
import numpy as np
import pytest
import pandas as pd
from pandas import Timestamp
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
def test_assert_numpy_array_equal_shape_mismatch():
msg = """numpy array are different
numpy array shapes are different
\\[left\\]: \\(2L*,\\)
\\[right\\]: \\(3L*,\\)"""
Reported by Pylint.
Line: 22
Column: 1
tm.assert_numpy_array_equal(np.array([1, 2]), np.array([3, 4, 5]))
def test_assert_numpy_array_equal_bad_type():
expected = "Expected type"
with pytest.raises(AssertionError, match=expected):
tm.assert_numpy_array_equal(1, 2)
Reported by Pylint.
Line: 32
Column: 1
@pytest.mark.parametrize(
"a,b,klass1,klass2",
[(np.array([1]), 1, "ndarray", "int"), (1, np.array([1]), "int", "ndarray")],
)
def test_assert_numpy_array_equal_class_mismatch(a, b, klass1, klass2):
msg = f"""numpy array are different
numpy array classes are different
\\[left\\]: {klass1}
Reported by Pylint.
Line: 32
Column: 1
@pytest.mark.parametrize(
"a,b,klass1,klass2",
[(np.array([1]), 1, "ndarray", "int"), (1, np.array([1]), "int", "ndarray")],
)
def test_assert_numpy_array_equal_class_mismatch(a, b, klass1, klass2):
msg = f"""numpy array are different
numpy array classes are different
\\[left\\]: {klass1}
Reported by Pylint.
Line: 32
Column: 1
@pytest.mark.parametrize(
"a,b,klass1,klass2",
[(np.array([1]), 1, "ndarray", "int"), (1, np.array([1]), "int", "ndarray")],
)
def test_assert_numpy_array_equal_class_mismatch(a, b, klass1, klass2):
msg = f"""numpy array are different
numpy array classes are different
\\[left\\]: {klass1}
Reported by Pylint.
Line: 44
Column: 1
tm.assert_numpy_array_equal(a, b)
def test_assert_numpy_array_equal_value_mismatch1():
msg = """numpy array are different
numpy array values are different \\(66\\.66667 %\\)
\\[left\\]: \\[nan, 2\\.0, 3\\.0\\]
\\[right\\]: \\[1\\.0, nan, 3\\.0\\]"""
Reported by Pylint.
Line: 55
Column: 1
tm.assert_numpy_array_equal(np.array([np.nan, 2, 3]), np.array([1, np.nan, 3]))
def test_assert_numpy_array_equal_value_mismatch2():
msg = """numpy array are different
numpy array values are different \\(50\\.0 %\\)
\\[left\\]: \\[1, 2\\]
\\[right\\]: \\[1, 3\\]"""
Reported by Pylint.
Line: 66
Column: 1
tm.assert_numpy_array_equal(np.array([1, 2]), np.array([1, 3]))
def test_assert_numpy_array_equal_value_mismatch3():
msg = """numpy array are different
numpy array values are different \\(16\\.66667 %\\)
\\[left\\]: \\[\\[1, 2\\], \\[3, 4\\], \\[5, 6\\]\\]
\\[right\\]: \\[\\[1, 3\\], \\[3, 4\\], \\[5, 6\\]\\]"""
Reported by Pylint.
asv_bench/benchmarks/attrs_caching.py
29 issues
Line: 3
Column: 1
import numpy as np
import pandas as pd
from pandas import DataFrame
try:
from pandas.core.construction import extract_array
except ImportError:
extract_array = None
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pandas as pd
from pandas import DataFrame
try:
from pandas.core.construction import extract_array
except ImportError:
extract_array = None
Reported by Pylint.
Line: 51
Column: 1
extract_array(self.series, extract_numpy=True)
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 14
Column: 9
class DataFrameAttributes:
def setup(self):
self.df = DataFrame(np.random.randn(10, 6))
self.cur_index = self.df.index
def time_get_index(self):
self.foo = self.df.index
Reported by Pylint.
Line: 15
Column: 9
class DataFrameAttributes:
def setup(self):
self.df = DataFrame(np.random.randn(10, 6))
self.cur_index = self.df.index
def time_get_index(self):
self.foo = self.df.index
def time_set_index(self):
Reported by Pylint.
Line: 18
Column: 9
self.cur_index = self.df.index
def time_get_index(self):
self.foo = self.df.index
def time_set_index(self):
self.df.index = self.cur_index
Reported by Pylint.
Line: 31
Column: 13
def setup(self, dtype):
if dtype == "numeric":
self.series = pd.Series([1, 2, 3])
elif dtype == "object":
self.series = pd.Series(["a", "b", "c"], dtype=object)
elif dtype == "category":
self.series = pd.Series(["a", "b", "c"], dtype="category")
elif dtype == "datetime64":
Reported by Pylint.
Line: 33
Column: 13
if dtype == "numeric":
self.series = pd.Series([1, 2, 3])
elif dtype == "object":
self.series = pd.Series(["a", "b", "c"], dtype=object)
elif dtype == "category":
self.series = pd.Series(["a", "b", "c"], dtype="category")
elif dtype == "datetime64":
self.series = pd.Series(pd.date_range("2013", periods=3))
elif dtype == "datetime64tz":
Reported by Pylint.
Line: 35
Column: 13
elif dtype == "object":
self.series = pd.Series(["a", "b", "c"], dtype=object)
elif dtype == "category":
self.series = pd.Series(["a", "b", "c"], dtype="category")
elif dtype == "datetime64":
self.series = pd.Series(pd.date_range("2013", periods=3))
elif dtype == "datetime64tz":
self.series = pd.Series(pd.date_range("2013", periods=3, tz="UTC"))
Reported by Pylint.
Line: 37
Column: 13
elif dtype == "category":
self.series = pd.Series(["a", "b", "c"], dtype="category")
elif dtype == "datetime64":
self.series = pd.Series(pd.date_range("2013", periods=3))
elif dtype == "datetime64tz":
self.series = pd.Series(pd.date_range("2013", periods=3, tz="UTC"))
def time_array(self, dtype):
self.series.array
Reported by Pylint.
pandas/tests/series/methods/test_nlargest.py
29 issues
Line: 8
Column: 1
from itertools import product
import numpy as np
import pytest
import pandas as pd
from pandas import Series
import pandas._testing as tm
Reported by Pylint.
Line: 72
Column: 34
@pytest.fixture(params=main_dtypes)
def s_main_dtypes_split(request, s_main_dtypes):
"""Each series in s_main_dtypes."""
return s_main_dtypes[request.param]
def assert_check_nselect_boundary(vals, dtype, method):
Reported by Pylint.
Line: 108
Column: 39
with pytest.raises(TypeError, match=msg):
method(arg)
def test_nsmallest_nlargest(self, s_main_dtypes_split):
# float, int, datetime64 (use i8), timedelts64 (same),
# object that are numbers, object that are strings
ser = s_main_dtypes_split
tm.assert_series_equal(ser.nsmallest(2), ser.iloc[[2, 1]])
Reported by Pylint.
Line: 44
Column: 5
The columns are the name of the dtype.
"""
df = pd.DataFrame(
{
"datetime": pd.to_datetime(["2003", "2002", "2001", "2002", "2005"]),
"datetimetz": pd.to_datetime(
["2003", "2002", "2001", "2002", "2005"]
).tz_localize("US/Eastern"),
Reported by Pylint.
Line: 77
Column: 1
return s_main_dtypes[request.param]
def assert_check_nselect_boundary(vals, dtype, method):
# helper function for 'test_boundary_{dtype}' tests
ser = Series(vals, dtype=dtype)
result = getattr(ser, method)(3)
expected_idxr = [0, 1, 2] if method == "nsmallest" else [3, 2, 1]
expected = ser.loc[expected_idxr]
Reported by Pylint.
Line: 86
Column: 1
tm.assert_series_equal(result, expected)
class TestSeriesNLargestNSmallest:
@pytest.mark.parametrize(
"r",
[
Series([3.0, 2, 1, 2, "5"], dtype="object"),
Series([3.0, 2, 1, 2, 5], dtype="object"),
Reported by Pylint.
Line: 97
Column: 5
Series([3.0, 2, 1, 2, 5], dtype="complex128"),
Series(list("abcde")),
Series(list("abcde"), dtype="category"),
],
)
def test_nlargest_error(self, r):
dt = r.dtype
msg = f"Cannot use method 'n(largest|smallest)' with dtype {dt}"
args = 2, len(r), 0, -1
Reported by Pylint.
Line: 97
Column: 5
Series([3.0, 2, 1, 2, 5], dtype="complex128"),
Series(list("abcde")),
Series(list("abcde"), dtype="category"),
],
)
def test_nlargest_error(self, r):
dt = r.dtype
msg = f"Cannot use method 'n(largest|smallest)' with dtype {dt}"
args = 2, len(r), 0, -1
Reported by Pylint.
Line: 97
Column: 5
Series([3.0, 2, 1, 2, 5], dtype="complex128"),
Series(list("abcde")),
Series(list("abcde"), dtype="category"),
],
)
def test_nlargest_error(self, r):
dt = r.dtype
msg = f"Cannot use method 'n(largest|smallest)' with dtype {dt}"
args = 2, len(r), 0, -1
Reported by Pylint.
Line: 100
Column: 9
],
)
def test_nlargest_error(self, r):
dt = r.dtype
msg = f"Cannot use method 'n(largest|smallest)' with dtype {dt}"
args = 2, len(r), 0, -1
methods = r.nlargest, r.nsmallest
for method, arg in product(methods, args):
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
pandas/io/parquet.py
29 issues
Line: 150
Column: 9
import_optional_dependency(
"pyarrow", extra="pyarrow is required for parquet support."
)
import pyarrow.parquet
# import utils to register the pyarrow extension types
import pandas.core.arrays._arrow_utils # noqa
self.api = pyarrow
Reported by Pylint.
Line: 153
Column: 9
import pyarrow.parquet
# import utils to register the pyarrow extension types
import pandas.core.arrays._arrow_utils # noqa
self.api = pyarrow
def write(
self,
Reported by Pylint.
Line: 157
Column: 5
self.api = pyarrow
def write(
self,
df: DataFrame,
path: FilePathOrBuffer[AnyStr],
compression: str | None = "snappy",
index: bool | None = None,
Reported by Pylint.
Line: 201
Column: 5
if handles is not None:
handles.close()
def read(
self,
path,
columns=None,
use_nullable_dtypes=False,
storage_options: StorageOptions = None,
Reported by Pylint.
Line: 243
Column: 26
path_or_handle, columns=columns, **kwargs
).to_pandas(**to_pandas_kwargs)
if manager == "array":
result = result._as_manager("array", copy=False)
return result
finally:
if handles is not None:
handles.close()
Reported by Pylint.
Line: 259
Column: 5
)
self.api = fastparquet
def write(
self,
df: DataFrame,
path,
compression="snappy",
index=None,
Reported by Pylint.
Line: 309
Column: 5
**kwargs,
)
def read(
self, path, columns=None, storage_options: StorageOptions = None, **kwargs
):
parquet_kwargs: dict[str, Any] = {}
use_nullable_dtypes = kwargs.pop("use_nullable_dtypes", False)
if Version(self.api.__version__) >= Version("0.7.0"):
Reported by Pylint.
Line: 353
Column: 22
return result
@doc(storage_options=generic._shared_docs["storage_options"])
def to_parquet(
df: DataFrame,
path: FilePathOrBuffer | None = None,
engine: str = "auto",
compression: str | None = "snappy",
Reported by Pylint.
Line: 437
Column: 22
return None
@doc(storage_options=generic._shared_docs["storage_options"])
def read_parquet(
path,
engine: str = "auto",
columns=None,
storage_options: StorageOptions = None,
Reported by Pylint.
Line: 63
Column: 5
f"{error_msgs}"
)
if engine == "pyarrow":
return PyArrowImpl()
elif engine == "fastparquet":
return FastParquetImpl()
raise ValueError("engine must be one of 'pyarrow', 'fastparquet'")
Reported by Pylint.
pandas/io/formats/csvs.py
29 issues
Line: 20
Column: 1
import numpy as np
from pandas._libs import writers as libwriters
from pandas._typing import (
CompressionOptions,
FilePathOrBuffer,
FloatFormatType,
IndexLabel,
Reported by Pylint.
Line: 151
Column: 24
if cols is not None:
if isinstance(cols, ABCIndex):
cols = cols._format_native_types(**self._number_format)
else:
cols = list(cols)
self.obj = self.obj.loc[:, cols]
# update columns to include possible multiplicity of dupes
Reported by Pylint.
Line: 159
Column: 16
# update columns to include possible multiplicity of dupes
# and make sure cols is just a list of labels
new_cols = self.obj.columns
return new_cols._format_native_types(**self._number_format)
def _initialize_chunksize(self, chunksize: int | None) -> int:
if chunksize is None:
return (100000 // (len(self.cols) or 1)) or 1
return int(chunksize)
Reported by Pylint.
Line: 247
Column: 13
) as handles:
# Note: self.encoding is irrelevant here
self.writer = csvlib.writer(
handles.handle, # type: ignore[arg-type]
lineterminator=self.line_terminator,
delimiter=self.sep,
quoting=self.quoting,
doublequote=self.doublequote,
Reported by Pylint.
Line: 283
Column: 29
if isinstance(self.index_label, list) and len(self.index_label) > 1:
col_line.extend([""] * (len(self.index_label) - 1))
col_line.extend(columns._get_level_values(i))
yield col_line
# Write out the index line if it's not empty.
# Otherwise, we will print out an extraneous
# blank line between the mi and the data rows.
Reported by Pylint.
Line: 307
Column: 15
slicer = slice(start_i, end_i)
df = self.obj.iloc[slicer]
res = df._mgr.to_native_types(**self._number_format)
data = [res.iget_values(i) for i in range(len(res.items))]
ix = self.data_index[slicer]._format_native_types(**self._number_format)
libwriters.write_csv_rows(
data,
Reported by Pylint.
Line: 310
Column: 14
res = df._mgr.to_native_types(**self._number_format)
data = [res.iget_values(i) for i in range(len(res.items))]
ix = self.data_index[slicer]._format_native_types(**self._number_format)
libwriters.write_csv_rows(
data,
ix,
self.nlevels,
self.cols,
Reported by Pylint.
Line: 45
Column: 1
from pandas.io.formats.format import DataFrameFormatter
class CSVFormatter:
cols: np.ndarray
def __init__(
self,
formatter: DataFrameFormatter,
Reported by Pylint.
Line: 45
Column: 1
from pandas.io.formats.format import DataFrameFormatter
class CSVFormatter:
cols: np.ndarray
def __init__(
self,
formatter: DataFrameFormatter,
Reported by Pylint.
Line: 48
Column: 5
class CSVFormatter:
cols: np.ndarray
def __init__(
self,
formatter: DataFrameFormatter,
path_or_buf: FilePathOrBuffer[str] | FilePathOrBuffer[bytes] = "",
sep: str = ",",
cols: Sequence[Hashable] | None = None,
Reported by Pylint.