The following issues were found
pandas/tests/extension/base/reshaping.py
94 issues
Line: 4
Column: 1
import itertools
import numpy as np
import pytest
from pandas.core.dtypes.common import (
is_datetime64tz_dtype,
is_interval_dtype,
is_period_dtype,
Reported by Pylint.
Line: 36
Column: 20
dtype = result.dtype
assert dtype == data.dtype
if hasattr(result._mgr, "blocks"):
assert isinstance(result._mgr.blocks[0], ExtensionBlock)
assert isinstance(result._mgr.arrays[0], ExtensionArray)
@pytest.mark.parametrize("in_frame", [True, False])
def test_concat_all_na_block(self, data_missing, in_frame):
Reported by Pylint.
Line: 37
Column: 31
assert dtype == data.dtype
if hasattr(result._mgr, "blocks"):
assert isinstance(result._mgr.blocks[0], ExtensionBlock)
assert isinstance(result._mgr.arrays[0], ExtensionArray)
@pytest.mark.parametrize("in_frame", [True, False])
def test_concat_all_na_block(self, data_missing, in_frame):
valid_block = pd.Series(data_missing.take([1, 1]), index=[0, 1])
Reported by Pylint.
Line: 38
Column: 27
assert dtype == data.dtype
if hasattr(result._mgr, "blocks"):
assert isinstance(result._mgr.blocks[0], ExtensionBlock)
assert isinstance(result._mgr.arrays[0], ExtensionArray)
@pytest.mark.parametrize("in_frame", [True, False])
def test_concat_all_na_block(self, data_missing, in_frame):
valid_block = pd.Series(data_missing.take([1, 1]), index=[0, 1])
na_block = pd.Series(data_missing.take([0, 0]), index=[2, 3])
Reported by Pylint.
Line: 95
Column: 22
df2 = pd.DataFrame({"B": [1, 2, 3]}, index=[1, 2, 3])
expected = pd.DataFrame(
{
"A": data._from_sequence(list(data[:3]) + [na_value], dtype=data.dtype),
"B": [np.nan, 1, 2, 3],
}
)
result = pd.concat([df1, df2], axis=1)
Reported by Pylint.
Line: 111
Column: 22
df2 = pd.DataFrame({"B": data[3:7]})
expected = pd.DataFrame(
{
"A": data._from_sequence(list(data[:3]) + [na_value], dtype=data.dtype),
"B": data[3:7],
}
)
result = pd.concat([df1, df2], axis=1, copy=False)
self.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 137
Column: 24
r1, r2 = pd.Series(a).align(pd.Series(b, index=[1, 2, 3]))
# Assumes that the ctor can take a list of scalars of the type
e1 = pd.Series(data._from_sequence(list(a) + [na_value], dtype=data.dtype))
e2 = pd.Series(data._from_sequence([na_value] + list(b), dtype=data.dtype))
self.assert_series_equal(r1, e1)
self.assert_series_equal(r2, e2)
def test_align_frame(self, data, na_value):
Reported by Pylint.
Line: 138
Column: 24
# Assumes that the ctor can take a list of scalars of the type
e1 = pd.Series(data._from_sequence(list(a) + [na_value], dtype=data.dtype))
e2 = pd.Series(data._from_sequence([na_value] + list(b), dtype=data.dtype))
self.assert_series_equal(r1, e1)
self.assert_series_equal(r2, e2)
def test_align_frame(self, data, na_value):
a = data[:3]
Reported by Pylint.
Line: 149
Column: 19
# Assumes that the ctor can take a list of scalars of the type
e1 = pd.DataFrame(
{"A": data._from_sequence(list(a) + [na_value], dtype=data.dtype)}
)
e2 = pd.DataFrame(
{"A": data._from_sequence([na_value] + list(b), dtype=data.dtype)}
)
self.assert_frame_equal(r1, e1)
Reported by Pylint.
Line: 152
Column: 19
{"A": data._from_sequence(list(a) + [na_value], dtype=data.dtype)}
)
e2 = pd.DataFrame(
{"A": data._from_sequence([na_value] + list(b), dtype=data.dtype)}
)
self.assert_frame_equal(r1, e1)
self.assert_frame_equal(r2, e2)
def test_align_series_frame(self, data, na_value):
Reported by Pylint.
pandas/tests/util/test_assert_almost_equal.py
94 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
Series,
Timestamp,
)
Reported by Pylint.
Line: 69
Column: 5
The arguments passed to `tm.assert_almost_equal`.
"""
_assert_not_almost_equal(a, b, **kwargs)
_assert_not_almost_equal(b, a, **kwargs)
@pytest.mark.parametrize(
"a,b,check_less_precise",
[(1.1, 1.1, False), (1.1, 1.100001, True), (1.1, 1.1001, 2)],
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
Series,
Timestamp,
)
Reported by Pylint.
Line: 13
Column: 1
import pandas._testing as tm
def _assert_almost_equal_both(a, b, **kwargs):
"""
Check that two objects are approximately equal.
This check is performed commutatively.
Reported by Pylint.
Line: 13
Column: 1
import pandas._testing as tm
def _assert_almost_equal_both(a, b, **kwargs):
"""
Check that two objects are approximately equal.
This check is performed commutatively.
Reported by Pylint.
Line: 32
Column: 1
tm.assert_almost_equal(b, a, **kwargs)
def _assert_not_almost_equal(a, b, **kwargs):
"""
Check that two objects are not approximately equal.
Parameters
----------
Reported by Pylint.
Line: 32
Column: 1
tm.assert_almost_equal(b, a, **kwargs)
def _assert_not_almost_equal(a, b, **kwargs):
"""
Check that two objects are not approximately equal.
Parameters
----------
Reported by Pylint.
Line: 53
Column: 1
pass
def _assert_not_almost_equal_both(a, b, **kwargs):
"""
Check that two objects are not approximately equal.
This check is performed commutatively.
Reported by Pylint.
Line: 53
Column: 1
pass
def _assert_not_almost_equal_both(a, b, **kwargs):
"""
Check that two objects are not approximately equal.
This check is performed commutatively.
Reported by Pylint.
Line: 75
Column: 1
@pytest.mark.parametrize(
"a,b,check_less_precise",
[(1.1, 1.1, False), (1.1, 1.100001, True), (1.1, 1.1001, 2)],
)
def test_assert_almost_equal_deprecated(a, b, check_less_precise):
# GH#30562
with tm.assert_produces_warning(FutureWarning):
_assert_almost_equal_both(a, b, check_less_precise=check_less_precise)
Reported by Pylint.
pandas/tests/indexes/test_common.py
94 issues
Line: 9
Column: 1
import re
import numpy as np
import pytest
from pandas._libs.tslibs import iNaT
from pandas.compat import IS64
from pandas.core.dtypes.common import (
Reported by Pylint.
Line: 77
Column: 34
def test_constructor_unwraps_index(self, index_flat):
a = index_flat
b = type(a)(a)
tm.assert_equal(a._data, b._data)
def test_to_flat_index(self, index_flat):
# 22866
index = index_flat
Reported by Pylint.
Line: 77
Column: 25
def test_constructor_unwraps_index(self, index_flat):
a = index_flat
b = type(a)(a)
tm.assert_equal(a._data, b._data)
def test_to_flat_index(self, index_flat):
# 22866
index = index_flat
Reported by Pylint.
Line: 101
Column: 3
assert res is None
assert index.name == new_name
assert index.names == [new_name]
# FIXME: dont leave commented-out
# with pytest.raises(TypeError, match="list-like"):
# # should still fail even if it would be the right length
# ind.set_names("a")
with pytest.raises(ValueError, match="Level must be None"):
index.set_names("a", level=0)
Reported by Pylint.
Line: 172
Column: 16
tm.assert_index_equal(result, idx_unique)
# nans:
if not index._can_hold_na:
pytest.skip("Skip na-check if index cannot hold na")
if is_period_dtype(index.dtype):
vals = index[[0] * 5]._data
vals[0] = pd.NaT
Reported by Pylint.
Line: 176
Column: 20
pytest.skip("Skip na-check if index cannot hold na")
if is_period_dtype(index.dtype):
vals = index[[0] * 5]._data
vals[0] = pd.NaT
elif needs_i8_conversion(index.dtype):
vals = index._data._ndarray[[0] * 5]
vals[0] = iNaT
else:
Reported by Pylint.
Line: 179
Column: 20
vals = index[[0] * 5]._data
vals[0] = pd.NaT
elif needs_i8_conversion(index.dtype):
vals = index._data._ndarray[[0] * 5]
vals[0] = iNaT
else:
vals = index.values[[0] * 5]
vals[0] = np.nan
Reported by Pylint.
Line: 179
Column: 20
vals = index[[0] * 5]._data
vals[0] = pd.NaT
elif needs_i8_conversion(index.dtype):
vals = index._data._ndarray[[0] * 5]
vals[0] = iNaT
else:
vals = index.values[[0] * 5]
vals[0] = np.nan
Reported by Pylint.
Line: 188
Column: 25
vals_unique = vals[:2]
if index.dtype.kind in ["m", "M"]:
# i.e. needs_i8_conversion but not period_dtype, as above
vals = type(index._data)(vals, dtype=index.dtype)
vals_unique = type(index._data)._simple_new(vals_unique, dtype=index.dtype)
idx_nan = index._shallow_copy(vals)
idx_unique_nan = index._shallow_copy(vals_unique)
assert idx_unique_nan.is_unique is True
Reported by Pylint.
Line: 189
Column: 32
if index.dtype.kind in ["m", "M"]:
# i.e. needs_i8_conversion but not period_dtype, as above
vals = type(index._data)(vals, dtype=index.dtype)
vals_unique = type(index._data)._simple_new(vals_unique, dtype=index.dtype)
idx_nan = index._shallow_copy(vals)
idx_unique_nan = index._shallow_copy(vals_unique)
assert idx_unique_nan.is_unique is True
assert idx_nan.dtype == index.dtype
Reported by Pylint.
pandas/io/sas/sas_constants.py
93 issues
Line: 1
Column: 1
magic = (
b"\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\xc2\xea\x81\x60"
+ b"\xb3\x14\x11\xcf\xbd\x92\x08\x00"
+ b"\x09\xc7\x31\x8c\x18\x1f\x10\x11"
)
align_1_checker_value = b"3"
align_1_offset = 32
Reported by Pylint.
Line: 1
Column: 1
magic = (
b"\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\xc2\xea\x81\x60"
+ b"\xb3\x14\x11\xcf\xbd\x92\x08\x00"
+ b"\x09\xc7\x31\x8c\x18\x1f\x10\x11"
)
align_1_checker_value = b"3"
align_1_offset = 32
Reported by Pylint.
Line: 8
Column: 1
+ b"\x09\xc7\x31\x8c\x18\x1f\x10\x11"
)
align_1_checker_value = b"3"
align_1_offset = 32
align_1_length = 1
align_1_value = 4
u64_byte_checker_value = b"3"
align_2_offset = 35
Reported by Pylint.
Line: 9
Column: 1
)
align_1_checker_value = b"3"
align_1_offset = 32
align_1_length = 1
align_1_value = 4
u64_byte_checker_value = b"3"
align_2_offset = 35
align_2_length = 1
Reported by Pylint.
Line: 10
Column: 1
align_1_checker_value = b"3"
align_1_offset = 32
align_1_length = 1
align_1_value = 4
u64_byte_checker_value = b"3"
align_2_offset = 35
align_2_length = 1
align_2_value = 4
Reported by Pylint.
Line: 11
Column: 1
align_1_checker_value = b"3"
align_1_offset = 32
align_1_length = 1
align_1_value = 4
u64_byte_checker_value = b"3"
align_2_offset = 35
align_2_length = 1
align_2_value = 4
endianness_offset = 37
Reported by Pylint.
Line: 12
Column: 1
align_1_offset = 32
align_1_length = 1
align_1_value = 4
u64_byte_checker_value = b"3"
align_2_offset = 35
align_2_length = 1
align_2_value = 4
endianness_offset = 37
endianness_length = 1
Reported by Pylint.
Line: 13
Column: 1
align_1_length = 1
align_1_value = 4
u64_byte_checker_value = b"3"
align_2_offset = 35
align_2_length = 1
align_2_value = 4
endianness_offset = 37
endianness_length = 1
platform_offset = 39
Reported by Pylint.
Line: 14
Column: 1
align_1_value = 4
u64_byte_checker_value = b"3"
align_2_offset = 35
align_2_length = 1
align_2_value = 4
endianness_offset = 37
endianness_length = 1
platform_offset = 39
platform_length = 1
Reported by Pylint.
Line: 15
Column: 1
u64_byte_checker_value = b"3"
align_2_offset = 35
align_2_length = 1
align_2_value = 4
endianness_offset = 37
endianness_length = 1
platform_offset = 39
platform_length = 1
encoding_offset = 70
Reported by Pylint.
pandas/tests/arrays/test_datetimes.py
93 issues
Line: 7
Column: 1
import operator
import numpy as np
import pytest
from pandas.core.dtypes.dtypes import DatetimeTZDtype
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 27
Column: 28
dti = pd.date_range("2016-01-1", freq="MS", periods=9, tz=None)
arr = DatetimeArray(dti)
assert arr.freq == dti.freq
assert arr.tz == dti.tz
right = dti
expected = np.ones(len(arr), dtype=bool)
Reported by Pylint.
Line: 27
Column: 28
dti = pd.date_range("2016-01-1", freq="MS", periods=9, tz=None)
arr = DatetimeArray(dti)
assert arr.freq == dti.freq
assert arr.tz == dti.tz
right = dti
expected = np.ones(len(arr), dtype=bool)
Reported by Pylint.
Line: 28
Column: 26
dti = pd.date_range("2016-01-1", freq="MS", periods=9, tz=None)
arr = DatetimeArray(dti)
assert arr.freq == dti.freq
assert arr.tz == dti.tz
right = dti
expected = np.ones(len(arr), dtype=bool)
if opname in ["ne", "gt", "lt"]:
Reported by Pylint.
Line: 28
Column: 26
dti = pd.date_range("2016-01-1", freq="MS", periods=9, tz=None)
arr = DatetimeArray(dti)
assert arr.freq == dti.freq
assert arr.tz == dti.tz
right = dti
expected = np.ones(len(arr), dtype=bool)
if opname in ["ne", "gt", "lt"]:
Reported by Pylint.
Line: 17
Column: 3
class TestDatetimeArrayComparisons:
# TODO: merge this into tests/arithmetic/test_datetime64 once it is
# sufficiently robust
def test_cmp_dt64_arraylike_tznaive(self, all_compare_operators):
# arbitrary tz-naive DatetimeIndex
opname = all_compare_operators.strip("_")
Reported by Pylint.
Line: 40
Column: 3
result = op(arr, arr)
tm.assert_numpy_array_equal(result, expected)
for other in [right, np.array(right)]:
# TODO: add list and tuple, and object-dtype once those
# are fixed in the constructor
result = op(arr, other)
tm.assert_numpy_array_equal(result, expected)
result = op(other, arr)
Reported by Pylint.
Line: 51
Column: 15
class TestDatetimeArray:
def test_astype_to_same(self):
arr = DatetimeArray._from_sequence(
["2000"], dtype=DatetimeTZDtype(tz="US/Central")
)
result = arr.astype(DatetimeTZDtype(tz="US/Central"), copy=False)
assert result is arr
Reported by Pylint.
Line: 78
Column: 15
@pytest.mark.parametrize("dtype", [int, np.int32, np.int64, "uint32", "uint64"])
def test_astype_int(self, dtype):
arr = DatetimeArray._from_sequence([pd.Timestamp("2000"), pd.Timestamp("2001")])
with tm.assert_produces_warning(FutureWarning):
# astype(int..) deprecated
result = arr.astype(dtype)
if np.dtype(dtype).kind == "u":
Reported by Pylint.
Line: 96
Column: 15
tm.assert_numpy_array_equal(result, expected)
def test_tz_setter_raises(self):
arr = DatetimeArray._from_sequence(
["2000"], dtype=DatetimeTZDtype(tz="US/Central")
)
with pytest.raises(AttributeError, match="tz_localize"):
arr.tz = "UTC"
Reported by Pylint.
pandas/tests/indexes/datetimes/methods/test_to_period.py
93 issues
Line: 5
Column: 1
import dateutil.tz
from dateutil.tz import tzlocal
import pytest
import pytz
from pandas._libs.tslibs.ccalendar import MONTHS
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
Reported by Pylint.
Line: 6
Column: 1
import dateutil.tz
from dateutil.tz import tzlocal
import pytest
import pytz
from pandas._libs.tslibs.ccalendar import MONTHS
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas import (
Reported by Pylint.
Line: 8
Column: 1
import pytest
import pytz
from pandas._libs.tslibs.ccalendar import MONTHS
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas import (
DatetimeIndex,
Period,
Reported by Pylint.
Line: 8
Column: 1
import pytest
import pytz
from pandas._libs.tslibs.ccalendar import MONTHS
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas import (
DatetimeIndex,
Period,
Reported by Pylint.
Line: 9
Column: 1
import pytz
from pandas._libs.tslibs.ccalendar import MONTHS
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas import (
DatetimeIndex,
Period,
PeriodIndex,
Reported by Pylint.
Line: 9
Column: 1
import pytz
from pandas._libs.tslibs.ccalendar import MONTHS
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas import (
DatetimeIndex,
Period,
PeriodIndex,
Reported by Pylint.
Line: 25
Column: 15
class TestToPeriod:
def test_dti_to_period(self):
dti = date_range(start="1/1/2005", end="12/1/2005", freq="M")
pi1 = dti.to_period()
pi2 = dti.to_period(freq="D")
pi3 = dti.to_period(freq="3D")
assert pi1[0] == Period("Jan 2005", freq="M")
assert pi2[0] == Period("1/31/2005", freq="D")
Reported by Pylint.
Line: 25
Column: 15
class TestToPeriod:
def test_dti_to_period(self):
dti = date_range(start="1/1/2005", end="12/1/2005", freq="M")
pi1 = dti.to_period()
pi2 = dti.to_period(freq="D")
pi3 = dti.to_period(freq="3D")
assert pi1[0] == Period("Jan 2005", freq="M")
assert pi2[0] == Period("1/31/2005", freq="D")
Reported by Pylint.
Line: 26
Column: 15
def test_dti_to_period(self):
dti = date_range(start="1/1/2005", end="12/1/2005", freq="M")
pi1 = dti.to_period()
pi2 = dti.to_period(freq="D")
pi3 = dti.to_period(freq="3D")
assert pi1[0] == Period("Jan 2005", freq="M")
assert pi2[0] == Period("1/31/2005", freq="D")
assert pi3[0] == Period("1/31/2005", freq="3D")
Reported by Pylint.
Line: 26
Column: 15
def test_dti_to_period(self):
dti = date_range(start="1/1/2005", end="12/1/2005", freq="M")
pi1 = dti.to_period()
pi2 = dti.to_period(freq="D")
pi3 = dti.to_period(freq="3D")
assert pi1[0] == Period("Jan 2005", freq="M")
assert pi2[0] == Period("1/31/2005", freq="D")
assert pi3[0] == Period("1/31/2005", freq="3D")
Reported by Pylint.
pandas/tests/extension/test_numpy.py
92 issues
Line: 17
Column: 1
"""
import numpy as np
import pytest
from pandas.core.dtypes.cast import can_hold_element
from pandas.core.dtypes.dtypes import (
ExtensionDtype,
PandasDtype,
Reported by Pylint.
Line: 87
Column: 10
@pytest.fixture
def data(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
return pd.Series([(i,) for i in range(100)]).array
return PandasArray(np.arange(1, 101, dtype=dtype._dtype))
Reported by Pylint.
Line: 87
Column: 27
@pytest.fixture
def data(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
return pd.Series([(i,) for i in range(100)]).array
return PandasArray(np.arange(1, 101, dtype=dtype._dtype))
Reported by Pylint.
Line: 87
Column: 10
@pytest.fixture
def data(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
return pd.Series([(i,) for i in range(100)]).array
return PandasArray(np.arange(1, 101, dtype=dtype._dtype))
Reported by Pylint.
Line: 90
Column: 48
def data(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
return pd.Series([(i,) for i in range(100)]).array
return PandasArray(np.arange(1, 101, dtype=dtype._dtype))
@pytest.fixture
def data_missing(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
Reported by Pylint.
Line: 94
Column: 18
@pytest.fixture
def data_missing(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
return PandasArray(np.array([np.nan, (1,)], dtype=object))
return PandasArray(np.array([np.nan, 1.0]))
Reported by Pylint.
Line: 94
Column: 35
@pytest.fixture
def data_missing(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
return PandasArray(np.array([np.nan, (1,)], dtype=object))
return PandasArray(np.array([np.nan, 1.0]))
Reported by Pylint.
Line: 94
Column: 18
@pytest.fixture
def data_missing(allow_in_pandas, dtype):
if dtype.numpy_dtype == "object":
return PandasArray(np.array([np.nan, (1,)], dtype=object))
return PandasArray(np.array([np.nan, 1.0]))
Reported by Pylint.
Line: 114
Column: 39
@pytest.fixture
def data_for_sorting(allow_in_pandas, dtype):
"""Length-3 array with a known sort order.
This should be three items [B, C, A] with
A < B < C
"""
Reported by Pylint.
Line: 114
Column: 22
@pytest.fixture
def data_for_sorting(allow_in_pandas, dtype):
"""Length-3 array with a known sort order.
This should be three items [B, C, A] with
A < B < C
"""
Reported by Pylint.
pandas/tests/io/parser/test_network.py
92 issues
Line: 12
Column: 1
import logging
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import DataFrame
import pandas._testing as tm
Reported by Pylint.
Line: 219
Column: 9
def test_write_s3_csv_fails(self, tips_df, s3so):
# GH 32486
# Attempting to write to an invalid S3 path should raise
import botocore
# GH 34087
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html
# Catch a ClientError since AWS Service Errors are defined dynamically
error = (FileNotFoundError, botocore.exceptions.ClientError)
Reported by Pylint.
Line: 236
Column: 9
def test_write_s3_parquet_fails(self, tips_df, s3so):
# GH 27679
# Attempting to write to an invalid S3 path should raise
import botocore
# GH 34087
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html
# Catch a ClientError since AWS Service Errors are defined dynamically
error = (FileNotFoundError, botocore.exceptions.ClientError)
Reported by Pylint.
Line: 266
Column: 9
def test_read_csv_chunked_download(self, s3_resource, caplog, s3so):
# 8 MB, S3FS uses 5MB chunks
import s3fs
df = DataFrame(np.random.randn(100000, 4), columns=list("abcd"))
str_buf = StringIO()
df.to_csv(str_buf)
Reported by Pylint.
Line: 77
Column: 43
@td.skip_if_not_us_locale()
class TestS3:
@td.skip_if_no("s3fs")
def test_parse_public_s3_bucket(self, tips_df, s3so):
# more of an integration test due to the not-public contents portion
# can probably mock this though.
for ext, comp in [("", None), (".gz", "gzip"), (".bz2", "bz2")]:
df = read_csv(
Reported by Pylint.
Line: 97
Column: 44
assert not df.empty
tm.assert_frame_equal(df, tips_df)
def test_parse_public_s3n_bucket(self, tips_df, s3so):
# Read from AWS s3 as "s3n" URL
df = read_csv("s3n://pandas-test/tips.csv", nrows=10, storage_options=s3so)
assert isinstance(df, DataFrame)
assert not df.empty
Reported by Pylint.
Line: 105
Column: 44
assert not df.empty
tm.assert_frame_equal(tips_df.iloc[:10], df)
def test_parse_public_s3a_bucket(self, tips_df, s3so):
# Read from AWS s3 as "s3a" URL
df = read_csv("s3a://pandas-test/tips.csv", nrows=10, storage_options=s3so)
assert isinstance(df, DataFrame)
assert not df.empty
tm.assert_frame_equal(tips_df.iloc[:10], df)
Reported by Pylint.
Line: 112
Column: 49
assert not df.empty
tm.assert_frame_equal(tips_df.iloc[:10], df)
def test_parse_public_s3_bucket_nrows(self, tips_df, s3so):
for ext, comp in [("", None), (".gz", "gzip"), (".bz2", "bz2")]:
df = read_csv(
"s3://pandas-test/tips.csv" + ext,
nrows=10,
compression=comp,
Reported by Pylint.
Line: 124
Column: 51
assert not df.empty
tm.assert_frame_equal(tips_df.iloc[:10], df)
def test_parse_public_s3_bucket_chunked(self, tips_df, s3so):
# Read with a chunksize
chunksize = 5
for ext, comp in [("", None), (".gz", "gzip"), (".bz2", "bz2")]:
with read_csv(
"s3://pandas-test/tips.csv" + ext,
Reported by Pylint.
Line: 146
Column: 58
]
tm.assert_frame_equal(true_df, df)
def test_parse_public_s3_bucket_chunked_python(self, tips_df, s3so):
# Read with a chunksize using the Python parser
chunksize = 5
for ext, comp in [("", None), (".gz", "gzip"), (".bz2", "bz2")]:
with read_csv(
"s3://pandas-test/tips.csv" + ext,
Reported by Pylint.
pandas/tests/scalar/timestamp/test_arithmetic.py
91 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
from pandas._libs.tslibs import (
OutOfBoundsDatetime,
Timedelta,
Timestamp,
Reported by Pylint.
Line: 9
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs import (
OutOfBoundsDatetime,
Timedelta,
Timestamp,
offsets,
to_offset,
Reported by Pylint.
Line: 51
Column: 13
)
with pytest.raises(OverflowError, match=lmsg):
stamp + offset_overflow
with pytest.raises(OverflowError, match=msg):
offset_overflow + stamp
with pytest.raises(OverflowError, match=lmsg):
Reported by Pylint.
Line: 54
Column: 13
stamp + offset_overflow
with pytest.raises(OverflowError, match=msg):
offset_overflow + stamp
with pytest.raises(OverflowError, match=lmsg):
stamp - offset_overflow
# xref https://github.com/pandas-dev/pandas/issues/14080
Reported by Pylint.
Line: 57
Column: 13
offset_overflow + stamp
with pytest.raises(OverflowError, match=lmsg):
stamp - offset_overflow
# xref https://github.com/pandas-dev/pandas/issues/14080
# used to crash, so check for proper overflow exception
stamp = Timestamp("2000/1/1")
Reported by Pylint.
Line: 66
Column: 13
offset_overflow = to_offset("D") * 100 ** 5
with pytest.raises(OverflowError, match=lmsg):
stamp + offset_overflow
with pytest.raises(OverflowError, match=msg):
offset_overflow + stamp
with pytest.raises(OverflowError, match=lmsg):
Reported by Pylint.
Line: 69
Column: 13
stamp + offset_overflow
with pytest.raises(OverflowError, match=msg):
offset_overflow + stamp
with pytest.raises(OverflowError, match=lmsg):
stamp - offset_overflow
def test_overflow_timestamp_raises(self):
Reported by Pylint.
Line: 72
Column: 13
offset_overflow + stamp
with pytest.raises(OverflowError, match=lmsg):
stamp - offset_overflow
def test_overflow_timestamp_raises(self):
# https://github.com/pandas-dev/pandas/issues/31774
msg = "Result is too large"
a = Timestamp("2101-01-01 00:00:00")
Reported by Pylint.
Line: 81
Column: 13
b = Timestamp("1688-01-01 00:00:00")
with pytest.raises(OutOfBoundsDatetime, match=msg):
a - b
# but we're OK for timestamp and datetime.datetime
assert (a - b.to_pydatetime()) == (a.to_pydatetime() - b)
def test_delta_preserve_nanos(self):
Reported by Pylint.
Line: 104
Column: 17
else:
msg = "subtraction must have"
with pytest.raises(TypeError, match=msg):
other.to_datetime64() - ts
def test_timestamp_sub_datetime(self):
dt = datetime(2013, 10, 12)
ts = Timestamp(datetime(2013, 10, 13))
assert (ts - dt).days == 1
Reported by Pylint.
pandas/core/arrays/datetimes.py
90 issues
Line: 19
Column: 1
import numpy as np
from pandas._libs import (
lib,
tslib,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
Reported by Pylint.
Line: 19
Column: 1
import numpy as np
from pandas._libs import (
lib,
tslib,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
Reported by Pylint.
Line: 23
Column: 1
lib,
tslib,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
BaseOffset,
NaT,
NaTType,
Resolution,
Reported by Pylint.
Line: 23
Column: 1
lib,
tslib,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
BaseOffset,
NaT,
NaTType,
Resolution,
Reported by Pylint.
Line: 24
Column: 1
tslib,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
BaseOffset,
NaT,
NaTType,
Resolution,
Timestamp,
Reported by Pylint.
Line: 24
Column: 1
tslib,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
BaseOffset,
NaT,
NaTType,
Resolution,
Timestamp,
Reported by Pylint.
Line: 24
Column: 1
tslib,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
BaseOffset,
NaT,
NaTType,
Resolution,
Timestamp,
Reported by Pylint.
Line: 24
Column: 1
tslib,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
BaseOffset,
NaT,
NaTType,
Resolution,
Timestamp,
Reported by Pylint.
Line: 115
Column: 18
def _field_accessor(name, field, docstring=None):
def f(self):
values = self._local_timestamps()
if field in self._bool_ops:
if field.endswith(("start", "end")):
freq = self.freq
month_kw = 12
Reported by Pylint.
Line: 117
Column: 21
def f(self):
values = self._local_timestamps()
if field in self._bool_ops:
if field.endswith(("start", "end")):
freq = self.freq
month_kw = 12
if freq:
kwds = freq.kwds
Reported by Pylint.