8000 BUG Series rolling count ignores min periods by fujiaxiang · Pull Request #31319 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG Series rolling count ignores min periods #31319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
b7fcb54
CLN: remove unnecessary overriding in subclasses (#30875)
jbrockmendel Jan 10, 2020
6f2c509
DEPR: fix missing stacklevel in pandas.core.index deprecation (#30878)
jorisvandenbossche Jan 10, 2020
d1b9598
DOC: Encourage use of pre-commit in the docs (#30864)
gfyoung Jan 10, 2020
447a3b0
WEB: Removing Discourse links (#30890)
datapythonista Jan 10, 2020
03cdcb6
WEB: Remove from roadmap moving the docstring script (#30893)
datapythonista Jan 10, 2020
0b4bac7
TYP: typing annotations (#30901)
ShaharNaveh Jan 10, 2020
f887eb0
TYP: offsets (#30897)
jbrockmendel Jan 10, 2020
6e9651e
BUG: pickle files left behind by tm.round_trip_pickle (#30906)
jbrockmendel Jan 11, 2020
398bf7d
BUG: Series rolling count ignores min_periods (GH26996)
fujiaxiang Jan 11, 2020
7f2948c
replace syntax with f-string (#30919)
HH-MWB Jan 11, 2020
939e7dd
CLN: F-strings (#30916)
dinasv Jan 11, 2020
b47a454
DOC: Fixture docs in pandas/conftest.py (#30917)
gfyoung Jan 11, 2020
75ecfa4
CLN: remove unnecesary _date_check_type (#30932)
jbrockmendel Jan 11, 2020
044559a
DOC: Fix SS03 docstring error (#30939)
galuhsahid Jan 12, 2020
28e909c
TYP: type up parts of series.py (#30761)
topper-123 Jan 12, 2020
4e2546d
STY: wrong placed space in strings (#30940)
ShaharNaveh Jan 12, 2020
45580a2
DOC: Fix whatsnew contributors section (#30926)
jschendel Jan 13, 2020
439d629
CI: numpydev changed double to single quote (#30952)
jbrockmendel Jan 13, 2020
46c2864
CLN: leftover ix checks (#30951)
jbrockmendel Jan 13, 2020
bbccf2d
DOC: Move import conventions from wiki to docs #30808 (#30888)
souvik3333 Jan 13, 2020
2c76d06
DOC: Move couple of deprecations whatsnew to correct section (#30961)
ryankarlos Jan 13, 2020
62d16ab
STY: concat strings that should not be seperated (#30942)
ShaharNaveh Jan 13, 2020
dd6e31a
REGR: Fixed hash_key=None for object values (#30900)
TomAugspurger Jan 13, 2020
bd63ece
CLN: remove no-op from indexing (#30934)
jbrockmendel Jan 13, 2020
7ba53f0
BUG: -1 to the power of pd.NA was returning -1 (#30960)
MarcoGorelli Jan 13, 2020
67fcdef
TYP: NDFrame.resample (#30947)
topper-123 Jan 13, 2020
993fdbe
DOC: whatsnew for 1.1 (#30972)
WillAyd Jan 13, 2020
6928327
CLN: misc cleanups (#30877)
jbrockmendel Jan 13, 2020
2bf0c9f
Compat for util.testing import (#30973)
TomAugspurger Jan 13, 2020
307137c
STY: concat strings (#30979)
ShaharNaveh Jan 13, 2020
2075539
Added small corrections to the test for interpolate limit_area (#30987)
cchwala Jan 13, 2020
8ff2ebd
STY: concat strings (#30991)
ShaharNaveh Jan 14, 2020
13b22fd
CLN: de-duplicate _getitem_scalar (#30992)
jbrockmendel Jan 14, 2020
0f048cb
CLN: remove geopandas compat code (#30909)
jbrockmendel Jan 14, 2020
b18024d
STY: Whitespaces placed at the beginning instead at the end of a line…
ShaharNaveh Jan 14, 2020
3471270
API: Disallow NaN in StringArray constructor (#30980)
TomAugspurger Jan 14, 2020
81d9636
BUG: ensure_datetime64ns with bigendian array (#30976)
jbrockmendel Jan 14, 2020
d78c061
ENH: Add Stata 119 writer (#30959)
bashtage Jan 14, 2020
1835064
TST: bare pytest raises (#31001)
ShaharNaveh Jan 14, 2020
ee83988
DOC: Changed links to sphinx documentation in contributing.rst file (…
Jan 14, 2020
8d093fe
TST: Insert 'match' to bare pytest raises (#30997)
ShaharNaveh Jan 14, 2020
3787133
DOC: Fixed documented value of `pd.NA ** 0` (#31005) (#31015)
TomAugspurger Jan 14, 2020
cb05c13
DOC: Clarified documentation for convert_dates and use_default_dates …
amilbourne Jan 14, 2020
6b87716
CI: Remove unrequired config (#31024)
alimcmaster1 Jan 15, 2020
6837794
BUG: Preserve string dtype in extract (#31018)
TomAugspurger Jan 15, 2020
51cb276
CLN: remove checks for inferred_dtype==unicode (#31020)
jbrockmendel Jan 15, 2020
4ed9a39
CLN: remove unused NDFrame methods (#30935)
jbrockmendel Jan 15, 2020
bea5789
doc: update copyright year (#31022)
simon04 Jan 15, 2020
d243ca0
REF: PeriodIndex.get_loc (#31021)
jbrockmendel Jan 15, 2020
9b0ef5d
refactor DTI.get_loc (#31023)
jbrockmendel Jan 15, 2020
698920f
REF: do all casting _before_ call to DatetimeEngine.get_loc (#30948)
jbrockmendel Jan 15, 2020
586bcb1
BUG: pivot_table with multi-index columns only fails (#31013)
charlesdong1991 Jan 15, 2020
ef0cf1e
REF: implement _split_op_result (#31027)
jbrockmendel Jan 15, 2020
030a35c
PERF: RangeIndex.get_loc (#30930)
jbrockmendel Jan 15, 2020
8718877
ENH/TST: Allow more keywords to ensure_clean (#30 8000 915)
gfyoung Jan 15, 2020
dd94e0d
BLD: More lightweight mypy pre-commit hook (#30814)
xhochy Jan 15, 2020
2cabca8
CI: Fix clipboard problems (#29712)
datapythonista Jan 15, 2020
9a68635
BUG: SystemError in df.sum (#30905)
jbrockmendel Jan 15, 2020
bc9d329
BUG: Fix Timestamp constructor changes value on ambiguous DST (#30995)
AlexKirko Jan 15, 2020
c139f08
a -> an (#31033)
Jan 16, 2020
2170f4e
CI: Using docstring validator from numpydoc (#30746)
datapythonista Jan 16, 2020
2ba6be7
TST: Disallow bare pytest.raises (#31045)
gdex1 Jan 16, 2020
5d49730
CLN: assorted cleanups (#31056)
jbrockmendel Jan 16, 2020
c040f14
CLN: remove redundant return value (#31065)
jbrockmendel Jan 16, 2020
22fe19c
TYP/CLN: Replaced "Optional[Hashable]" with "Label" from pandas._typi…
ShaharNaveh Jan 16, 2020
7eafd73
CLN: Removed unused varibles from for loops (#31059)
ShaharNaveh Jan 16, 2020
7a1dad1
CLN/STY: Some stuff that got the attention of my eye (#31076)
ShaharNaveh Jan 16, 2020
7b7bb83
CLN: Removed the same code in 'if' and the 'else' (#31081)
ShaharNaveh Jan 16, 2020
721a2eb
CLN: remove unnecessary arg from _to_dt64 (#30895)
jbrockmendel Jan 16, 2020
a8eaebf
CLN: simplify Float64Index.__contains__ (#30899)
jbrockmendel Jan 16, 2020
208bb41
DOC: Add pandas_path to the accesor list in the documentation (#30898)
pjbull Jan 16, 2020
171a1ed
TYP: _config/config.py && core/{apply,construction}.py (#30734)
ShaharNaveh Jan 16, 2020
e4a96bb
ENH: Add engine keyword to expanding.apply to utilize Numba (#30937)
mroeschke Jan 16, 2020
321bae6
automatic 'end' year of copyright (#31085)
ShaharNaveh Jan 16, 2020
b2c90cc
CLN: Remove download_wheels.py, moved to pandas-release (#31083)
datapythonista Jan 16, 2020
14ab82e
CLN: remove unused legacy pickle compat code (#31078)
jbrockmendel Jan 16, 2020
f6747b9
REF: stricter types for RangeIndex._simple_new (#31084)
jbrockmendel Jan 16, 2020
b68a9bb
WEB: Improving the sponsors in the web, and adding CZI (#31046)
datapythonista Jan 17, 2020
0f04c6a
CI/TST: fix failing tests in py37_np_dev (#31091)
ShaharNaveh Jan 17, 2020
d21638b
CLN: Regular expression clean as @jbrockmendel suggested (#31098)
ShaharNaveh Jan 17, 2020
5d471c9
Merge remote-tracking branch 'upstream/master' into series_rolling_co…
fujiaxiang Jan 17, 2020
a72eef5
DOC: Add missing docstrings in pd.Index (#31047)
galuhsahid Jan 17, 2020
47f4e61
ENH: handles min_periods argument in rolling.count (GH26996)
fujiaxiang Jan 17, 2020
fb0f96e
WEB: Styling blog (#31094)
datapythonista Jan 17, 2020
a0c7a8a
CLN: Index._values docstring + Block.internal/external_values (#31103)
jorisvandenbossche Jan 17, 2020
641346c
TST: Fix some bare pytest raises (#31105)
ShaharNaveh Jan 17, 2020
a890239
BUG: pd.crosstab(s1, s2) handle column index incorrectly when both se…
charlesdong1991 Jan 17, 2020
f873fb9
TYP: annotations (#31115)
jbrockmendel Jan 18, 2020
9c33464
JSON Date Handling 1.0 Regressions (#30977)
WillAyd Jan 18, 2020
4e9ee4d
BUG: reductions for nullable dtypes should return pd.NA for skipna=Fa…
jorisvandenbossche Jan 18, 2020
f19035d
REF: fix calls to Index.get_value (#31112)
jbrockmendel Jan 18, 2020
1c9f23c
CLN: prune unreachable code (#31106)
jbrockmendel Jan 18, 2020
df2a3e9
DOC: moved whatsnew to V1.1.0
fujiaxiang Jan 18, 2020
554abfa
Merge remote-tracking branch 'upstream/master' into series_rolling_co…
fujiaxiang Jan 18, 2020
65b23c2
BUG: partial-timestamp slicing near the end of year/quarter/month (#3…
jbrockmendel Jan 18, 2020
8b754fc
CLN: update _simple_new usages (#31089)
jbrockmendel Jan 18, 2020
024925a
REF: handle searchsorted casting within DatetimeLikeArray (#30950)
jbrockmendel Jan 18, 2020
55cfabb
REF: be stricter about what we pass to _simple_new (#31055)
jbrockmendel Jan 18, 2020
f792d8c
BUG: correct wrong error message in df.pivot when columns=None (#30925)
charlesdong1991 Jan 18, 2020
6245c70
Updated years in LICENSE (#31100)
ShaharNaveh Jan 18, 2020
d16dc5a
Pull Request Tips (#31093)
WillAyd Jan 18, 2020
a3c7722
DOC: Moved PANDAS_TESTING_MODE tip to .travis.yml (#30694) (#31008)
saloni30agr Jan 18, 2020
c4878b0
Merge remote-tracking branch 'upstream/master' into series_rolling_co…
fujiaxiang Jan 18, 2020
cdf6774
DOC: Replace ggpy with plotnine in ecosystem (#31097)
hvardhan20 Jan 18, 2020
d170cc0
TST/BUG: fix incorrectly-passing Exception (#30553)
jbrockmendel Jan 18, 2020
52c22b2
REF/CLN: Index.get_value wrapping incorrectly (#31125)
jbrockmendel Jan 18, 2020
a446979
REF: simplify Float64Index.get_loc (#31123)
jbrockmendel Jan 18, 2020
7d28040
ENH: Create DockerFile and devcontainer.json files to work with Docke…
yehoshuadimarsky Jan 19, 2020
b0f5baa
Merge remote-tracking branch 'upstream/master' into series_rolling_co…
fujiaxiang Jan 19, 2020
31a7f57
REF: share code between Int64Index and UInt64Index (#31129)
jbrockmendel Jan 19, 2020
ebaed91
REF: share code between Int64Index and UInt64Index (#31129)
jbrockmendel Jan 19, 2020
4f1afc4
REF: share code between Int64Index and UInt64Index (#31129)
jbrockmendel Jan 19, 2020
9843f43
REF: share code between Int64Index and UInt64Index (#31129)
jbrockmendel Jan 19, 2020
7c94949
TYP: Index get_indexer_foo methods (#31137)
jbrockmendel Jan 19, 2020
54ba6db
DOC: Fix HDF5 complevel and complib formatting (#31053)
kylekeppler Jan 20, 2020
212b714
DOC: Restore ExtensionIndex.dropna.__doc__ (#31095)
jbrockmendel Jan 20, 2020
eb492a2
Use Python 3 shebangs (#31147)
rebecca-palmer Jan 20, 2020
71b6833
REF/BUG: Index.get_value called incorrectly, de-duplicate+simplify (#…
jbrockmendel Jan 20, 2020
6a2f95b
REF: require PeriodArray in PeriodIndex._simple_new (#31128)
jbrockmendel Jan 20, 2020
be6a3bc
BUG: groupby apply raises ValueError when groupby axis has duplicates…
fujiaxiang Jan 20, 2020
f4de727
TST: insert 'match' to bare pytest raises in pandas/tests/internals/…
ShaharNaveh Jan 20, 2020
f8e905e
REF: share searchsorted between DTI/TDI/PI, insert between DTI/TDI (#…
jbrockmendel Jan 20, 2020
264363e
TYP: Annotations in pandas/core/nanops.py (#30461)
ShaharNaveh Jan 20, 2020
06e416d
BUG: raise on non-hashable in __contains__ (#30902)
jbrockmendel Jan 20, 2020
998e742
BUG: EAs should not be hashable (#30908)
jbrockmendel Jan 20, 2020
cd7c784
CLN: fix wrong types getting passed to TDI._get_string_slice (#30874)
jbrockmendel Jan 20, 2020
059742b
TYP: Type annotations in pandas/io/formats/style.py (#30403)
ShaharNaveh Jan 20, 2020
3fbc332
CLN: Remove unused release scripts (#31049)
datapythonista Jan 20, 2020
7882aac
:pencil: set klass correctly for series and dataframe set_axis (#30885)
MarcoGorelli Jan 20, 2020
15bacea
raise more specific error if dict is appended to frame wit… (#30882)
MarcoGorelli Jan 20, 2020
e0bd394
ENH Avoid redundant CSS in Styler.render (#30876)
jnothman Jan 20, 2020
cd20c95
REF: use _get_string_slice in PeriodIndex.get_value (#31058)
jbrockmendel Jan 20, 2020
f1aaf62
BUG: df.pivot_table fails when margin is True and only columns is def…
charlesdong1991 Jan 20, 2020
29edd11
BUG: Break reference from grouping level to MI (#31133)
TomAugspurger Jan 20, 2020
469b4b7
CLN/STY: various code cleanups (#31162)
ShaharNaveh Jan 20, 2020
24d7c06
BUG: Fix MutliIndexed unstack failures at tuple names (#30943)
charlesdong1991 Jan 20, 2020
9a01577
REF: Move generic methods to aggregation.py (#30856) 8000
charlesdong1991 Jan 20, 2020
f1bbb21
ENH: show percentiles in timestamp describe (#30164) (#30209)
david-cortes Jan 20, 2020
8a8e967
Split out JSON Date Converters (#31057)
WillAyd Jan 20, 2020
cdffa43
ENH: XLSB support (#29836)
Rik-de-Kort Jan 20, 2020
bbcda98
TST: Add regression tests for fixed issues (#31161)
mroeschke Jan 21, 2020
bfe10f0
TST: added more tests (GH26996)
fujiaxiang Jan 21, 2020
1a90629
Merge branch 'master' into series_rolling_count_ignores_min_periods
fujiaxiang Jan 21, 2020
964400d
Remove possibly illegal test data (#31146)
rebecca-palmer Jan 21, 2020
7ffcf9d
BUG: concat not copying index and columns when copy=True (#31119)
fujiaxiang Jan 21, 2020
be0926b
Merge remote-tracking branch 'upstream/master' into series_rolling_co…
fujiaxiang Jan 21, 2020
c0046b6
BUG: updated rolling and expanding count for consistency (GH26996)
fujiaxiang Jan 21, 2020
4050e4c
ENH: partial string indexing on non-monotonic PeriodIndex (#31096)
jbrockmendel Jan 21, 2020
d77b1d8
TST: Add more regression tests for fixed issues (#31171)
mroeschke Jan 21, 2020
e31c5ad
COMPAT: numpy test warnings (#30345)
nschloe Jan 21, 2020
c3f492f
REF: move misplaced tests (#31189)
jbrockmendel Jan 22, 2020
6dea557
CLN: remove unused fixtures (#31192)
jbrockmendel Jan 22, 2020
f4c99ff
REG: restore format_type attr (#31017)
jbrockmendel Jan 22, 2020
6752833
CI: numpydev ragged array dtype warning (#31203)
TomAugspurger Jan 22, 2020
8807ba1
CLN: further cleaned code (GH26996)
fujiaxiang Jan 22, 2020
118dc6c
DOC: fixup whatsnew (#31217)
TomAugspurger Jan 22, 2020
774498b
Follow-up: XLSB Support (#31215)
Rik-de-Kort Jan 22, 2020
6f395ad
Replaced set comprehension with a generator (#31229)
ShaharNaveh Jan 23, 2020
e83a6bd
BUG: Fixed upcast dtype for datetime64 in merge (#31211)
TomAugspurger Jan 23, 2020
7aa1582
Merge remote-tracking branch 'upstream/master' into series_rolling_co…
fujiaxiang Jan 23, 2020
bcce129
TST: cleaned up tests (GH26996)
fujiaxiang Jan 24, 2020
1a4352b
BUG: changed min_periods default to 0 for rolling and expanding (GH26…
fujiaxiang Jan 24, 2020
9fa4531
BUG: reverted non-relevant changes accidentally added (GH26996)
fujiaxiang Jan 24, 2020
987c033
BUG: small change in whatsnew (GH26996)
fujiaxiang Jan 25, 2020
a00532a
CLN: slight cleanup (GH26996)
fujiaxiang Jan 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
STY: concat strings that should not be seperated (#30942)
  • Loading branch information
ShaharNaveh authored and simonjayhawkins committed Jan 13, 2020
commit 62d16abd3051cacecfe6307be074acaa00587560
9 changes: 3 additions & 6 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,7 @@ def rank_1d(rank_t[:] in_arr, ties_method='average',
ranks[argsorted[j]] = i + 1
elif tiebreak == TIEBREAK_FIRST:
if rank_t is object:
raise ValueError('first not supported for '
'non-numeric data')
raise ValueError('first not supported for non-numeric data')
else:
for j in range(i - dups + 1, i + 1):
ranks[argsorted[j]] = j + 1
Expand Down Expand Up @@ -971,8 +970,7 @@ def rank_1d(rank_t[:] in_arr, ties_method='average',
ranks[argsorted[j]] = i + 1
elif tiebreak == TIEBREAK_FIRST:
if rank_t is object:
raise ValueError('first not supported for '
'non-numeric data')
raise ValueError('first not supported for non-numeric data')
else:
for j in range(i - dups + 1, i + 1):
ranks[argsorted[j]] = j + 1
Expand Down Expand Up @@ -1137,8 +1135,7 @@ def rank_2d(rank_t[:, :] in_arr, axis=0, ties_method='average',
ranks[i, argsorted[i, z]] = j + 1
elif tiebreak == TIEBREAK_FIRST:
if rank_t is object:
raise ValueError('first not supported '
'for non-numeric data')
raise ValueError('first not supported for non-numeric data')
else:
for z in range(j - dups + 1, j + 1):
ranks[i, argsorted[i, z]] = z + 1
Expand Down
3 changes: 1 addition & 2 deletions pandas/_libs/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,7 @@ def _group_ohlc(floating[:, :] out,
raise ValueError('Output array must have 4 columns')

if K > 1:
raise NotImplementedError("Argument 'values' must have only "
"one dimension")
raise NotImplementedError("Argument 'values' must have only one dimension")
out[:] = np.nan

with nogil:
Expand Down
11 changes: 7 additions & 4 deletions pandas/_libs/hashing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def hash_object_array(object[:] arr, object key, object encoding='utf8'):
k = <bytes>key.encode(encoding)
kb = <uint8_t *>k
if len(k) != 16:
raise ValueError("key should be a 16-byte string encoded, "
f"got {k} (len {len(k)})")
raise ValueError(
f"key should be a 16-byte string encoded, got {k} (len {len(k)})"
)

n = len(arr)

Expand All @@ -77,8 +78,10 @@ def hash_object_array(object[:] arr, object key, object encoding='utf8'):
hash(val)
data = <bytes>str(val).encode(encoding)
else:
raise TypeError(f"{val} of type {type(val)} is not a valid type "
"for hashing, must be string or null")
raise TypeError(
f"{val} of type {type(val)} is not a valid type for hashing, "
"must be string or null"
)

l = len(data)
lens[i] = l
Expand Down
5 changes: 3 additions & 2 deletions pandas/_libs/indexing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cdef class _NDFrameIndexerBase:
if ndim is None:
ndim = self._ndim = self.obj.ndim
if ndim > 2:
raise ValueError("NDFrameIndexer does not support "
"NDFrame objects with ndim > 2")
raise ValueError(
"NDFrameIndexer does not support NDFrame objects with ndim > 2"
)
return ndim
6 changes: 3 additions & 3 deletions pandas/_libs/sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ cdef class IntIndex(SparseIndex):
"""

if self.npoints > self.length:
msg = (f"Too many indices. Expected "
f"{self.length} but found {self.npoints}")
raise ValueError(msg)
raise ValueError(
f"Too many indices. Expected {self.length} but found {self.npoints}"
)

# Indices are vacuously ordered and non-negative
# if the sequence of indices is empty.
Expand Down
6 changes: 3 additions & 3 deletions pandas/_libs/testing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ cpdef assert_almost_equal(a, b,
# classes can't be the same, to raise error
assert_class_equal(a, b, obj=obj)

assert has_length(a) and has_length(b), ("Can't compare objects without "
"length, one or both is invalid: "
f"({a}, {b})")
assert has_length(a) and has_length(b), (
f"Can't compare objects without length, one or both is invalid: ({a}, {b})"
)

if a_is_ndarray and b_is_ndarray:
na, nb = a.size, b.size
Expand Down
74 changes: 47 additions & 27 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ def round_nsint64(values, mode, freq):

# if/elif above should catch all rounding modes defined in enum 'RoundTo':
# if flow of control arrives here, it is a bug
raise ValueError("round_nsint64 called with an unrecognized "
"rounding mode")
raise ValueError("round_nsint64 called with an unrecognized rounding mode")


# ----------------------------------------------------------------------
Expand Down Expand Up @@ -324,8 +323,10 @@ class Timestamp(_Timestamp):

Function is not implemented. Use pd.to_datetime().
"""
raise NotImplementedError("Timestamp.strptime() is not implemented."
"Use to_datetime() to parse date strings.")
raise NotImplementedError(
"Timestamp.strptime() is not implemented. "
"Use to_datetime() to parse date strings."
)

@classmethod
def combine(cls, date, time):
Expand Down Expand Up @@ -381,8 +382,9 @@ class Timestamp(_Timestamp):
if tzinfo is not None:
if not PyTZInfo_Check(tzinfo):
# tzinfo must be a datetime.tzinfo object, GH#17690
raise TypeError(f'tzinfo must be a datetime.tzinfo object, '
f'not {type(tzinfo)}')
raise TypeError(
f"tzinfo must be a datetime.tzinfo object, not {type(tzinfo)}"
)
elif tz is not None:
raise ValueError('Can provide at most one of tz, tzinfo')

Expand All @@ -393,8 +395,10 @@ class Timestamp(_Timestamp):
# User passed a date string to parse.
# Check that the user didn't also pass a date attribute kwarg.
if any(arg is not None for arg in _date_attributes):
raise ValueError('Cannot pass a date attribute keyword '
'argument when passing a date string')
raise ValueError(
"Cannot pass a date attribute keyword "
"argument when passing a date string"
)

elif ts_input is _no_input:
# User passed keyword arguments.
Expand Down Expand Up @@ -578,8 +582,10 @@ timedelta}, default 'raise'
@tz.setter
def tz(self, value):
# GH 3746: Prevent localizing or converting the index by setting tz
raise AttributeError("Cannot directly set timezone. Use tz_localize() "
"or tz_convert() as appropriate")
raise AttributeError(
"Cannot directly set timezone. "
"Use tz_localize() or tz_convert() as appropriate"
)

def __setstate__(self, state):
self.value = state[0]
Expand All @@ -598,9 +604,10 @@ timedelta}, default 'raise'

if self.tz is not None:
# GH#21333
warnings.warn("Converting to Period representation will "
"drop timezone information.",
UserWarning)
warnings.warn(
"Converting to Period representation will drop timezone information.",
UserWarning,
)

if freq is None:
freq = self.freq
Expand Down Expand Up @@ -810,13 +817,13 @@ default 'raise'
if ambiguous == 'infer':
raise ValueError('Cannot infer offset with only one time.')

nonexistent_options = ('raise', 'NaT', 'shift_forward',
'shift_backward')
nonexistent_options = ('raise', 'NaT', 'shift_forward', 'shift_backward')
if nonexistent not in nonexistent_options and not isinstance(
nonexistent, timedelta):
raise ValueError("The nonexistent argument must be one of 'raise', "
"'NaT', 'shift_forward', 'shift_backward' or "
"a timedelta object")
raise ValueError(
"The nonexistent argument must be one of 'raise', "
"'NaT', 'shift_forward', 'shift_backward' or a timedelta object"
)

if self.tzinfo is None:
# tz naive, localize
Expand All @@ -833,8 +840,9 @@ default 'raise'
value = tz_convert_single(self.value, UTC, self.tz)
return Timestamp(value, tz=tz, freq=self.freq)
else:
raise TypeError('Cannot localize tz-aware Timestamp, use '
'tz_convert for conversions')
raise TypeError(
"Cannot localize tz-aware Timestamp, use tz_convert for conversions"
)

def tz_convert(self, tz):
"""
Expand All @@ -857,17 +865,28 @@ default 'raise'
"""
if self.tzinfo is None:
# tz naive, use tz_localize
raise TypeError('Cannot convert tz-naive Timestamp, use '
'tz_localize to localize')
raise TypeError(
"Cannot convert tz-naive Timestamp, use tz_localize to localize"
)
else:
# Same UTC timestamp, different time zone
return Timestamp(self.value, tz=tz, freq=self.freq)

astimezone = tz_convert

def replace(self, year=None, month=None, day=None,
hour=None, minute=None, second=None, microsecond=None,
nanosecond=None, tzinfo=object, fold=0):
def replace(
self,
year=None,
month=None,
day=None,
hour=None,
minute=None,
second=None,
microsecond=None,
nanosecond=None,
tzinfo=object,
fold=0,
):
"""
implements datetime.replace, handles nanoseconds.

Expand Down Expand Up @@ -910,8 +929,9 @@ default 'raise'
def validate(k, v):
""" validate integers """
if not is_integer_object(v):
raise ValueError(f"value must be an integer, received "
f"{type(v)} for {k}")
raise ValueError(
f"value must be an integer, received {type(v)} for {k}"
)
return v

if year is not None:
Expand Down
3 changes: 1 addition & 2 deletions pandas/_libs/window/aggregations.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1871,8 +1871,7 @@ def ewmcov(float64_t[:] input_x, float64_t[:] input_y,
bint is_observation

if <Py_ssize_t>len(input_y) != N:
raise ValueError(f"arrays are of different lengths "
f"({N} and {len(input_y)})")
raise ValueError(f"arrays are of different lengths ({N} and {len(input_y)})")

output = np.empty(N, dtype=float)
if N == 0:
Expand Down
0