Skip to content

Commit fce06ce

Browse files
Kavya9986feefladder
authored andcommitted
Fixed all warning.warn messages for space,full-stop etc issues (pandas-dev#43163)
* Fixed all warning.warn messages for space,fullstop etc issues * fix ppe 8 issues reported * fix ppe 8 issues reported * fix ppe 8 issues reported * After precommit * fixed the expected variable * fixed flake8
1 parent b845cb4 commit fce06ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+89
-85
lines changed

pandas/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __getattr__(name):
207207
warnings.warn(
208208
"The pandas.np module is deprecated "
209209
"and will be removed from pandas in a future version. "
210-
"Import numpy directly instead",
210+
"Import numpy directly instead.",
211211
FutureWarning,
212212
stacklevel=2,
213213
)
@@ -218,7 +218,7 @@ def __getattr__(name):
218218
elif name in {"SparseSeries", "SparseDataFrame"}:
219219
warnings.warn(
220220
f"The {name} class is removed from pandas. Accessing it from "
221-
"the top-level namespace will also be removed in the next version",
221+
"the top-level namespace will also be removed in the next version.",
222222
FutureWarning,
223223
stacklevel=2,
224224
)

pandas/_libs/parsers.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ cdef class TextReader:
10001000
if col_dtype is not None:
10011001
warnings.warn((f"Both a converter and dtype were specified "
10021002
f"for column {name} - only the converter will "
1003-
f"be used"), ParserWarning,
1003+
f"be used."), ParserWarning,
10041004
stacklevel=5)
10051005
results[i] = _apply_converter(conv, self.parser, i, start, end)
10061006
continue

pandas/_libs/tslibs/nattype.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ cdef class _NaT(datetime):
143143
return True
144144
warnings.warn(
145145
"Comparison of NaT with datetime.date is deprecated in "
146-
"order to match the standard library behavior. "
146+
"order to match the standard library behavior. "
147147
"In a future version these will be considered non-comparable.",
148148
FutureWarning,
149149
stacklevel=1,

pandas/_libs/tslibs/offsets.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -696,15 +696,15 @@ cdef class BaseOffset:
696696

697697
def onOffset(self, dt) -> bool:
698698
warnings.warn(
699-
"onOffset is a deprecated, use is_on_offset instead",
699+
"onOffset is a deprecated, use is_on_offset instead.",
700700
FutureWarning,
701701
stacklevel=1,
702702
)
703703
return self.is_on_offset(dt)
704704

705705
def isAnchored(self) -> bool:
706706
warnings.warn(
707-
"isAnchored is a deprecated, use is_anchored instead",
707+
"isAnchored is a deprecated, use is_anchored instead.",
708708
FutureWarning,
709709
stacklevel=1,
710710
)

pandas/_libs/tslibs/timedeltas.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ cdef inline timedelta_from_spec(object number, object frac, object unit):
571571
if unit in ["M", "Y", "y"]:
572572
warnings.warn(
573573
"Units 'M', 'Y' and 'y' do not represent unambiguous "
574-
"timedelta values and will be removed in a future version",
574+
"timedelta values and will be removed in a future version.",
575575
FutureWarning,
576576
stacklevel=2,
577577
)

pandas/_libs/tslibs/timestamps.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ cdef class _Timestamp(ABCTimestamp):
171171
@property
172172
def freq(self):
173173
warnings.warn(
174-
"Timestamp.freq is deprecated and will be removed in a future version",
174+
"Timestamp.freq is deprecated and will be removed in a future version.",
175175
FutureWarning,
176176
stacklevel=1,
177177
)
@@ -235,8 +235,8 @@ cdef class _Timestamp(ABCTimestamp):
235235
# We follow the stdlib datetime behavior of never being equal
236236
warnings.warn(
237237
"Comparison of Timestamp with datetime.date is deprecated in "
238-
"order to match the standard library behavior. "
239-
"In a future version these will be considered non-comparable."
238+
"order to match the standard library behavior. "
239+
"In a future version these will be considered non-comparable. "
240240
"Use 'ts == pd.Timestamp(date)' or 'ts.date() == date' instead.",
241241
FutureWarning,
242242
stacklevel=1,
@@ -425,7 +425,7 @@ cdef class _Timestamp(ABCTimestamp):
425425
warnings.warn(
426426
"Timestamp.freq is deprecated and will be removed in a future "
427427
"version. When you have a freq, use "
428-
f"freq.{field}(timestamp) instead",
428+
f"freq.{field}(timestamp) instead.",
429429
FutureWarning,
430430
stacklevel=1,
431431
)
@@ -858,7 +858,7 @@ cdef class _Timestamp(ABCTimestamp):
858858
NaT
859859
"""
860860
if self.nanosecond != 0 and warn:
861-
warnings.warn("Discarding nonzero nanoseconds in conversion",
861+
warnings.warn("Discarding nonzero nanoseconds in conversion.",
862862
UserWarning, stacklevel=2)
863863

864864
return datetime(self.year, self.month, self.day,

pandas/core/arrays/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ def _addsub_object_array(self, other: np.ndarray, op):
11861186

11871187
warnings.warn(
11881188
"Adding/subtracting object-dtype array to "
1189-
f"{type(self).__name__} not vectorized",
1189+
f"{type(self).__name__} not vectorized.",
11901190
PerformanceWarning,
11911191
)
11921192

pandas/core/arrays/datetimes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ def _add_offset(self, offset) -> DatetimeArray:
744744

745745
except NotImplementedError:
746746
warnings.warn(
747-
"Non-vectorized DateOffset being applied to Series or DatetimeIndex",
747+
"Non-vectorized DateOffset being applied to Series or DatetimeIndex.",
748748
PerformanceWarning,
749749
)
750750
result = self.astype("O") + offset
@@ -1186,8 +1186,8 @@ def to_perioddelta(self, freq) -> TimedeltaArray:
11861186
# Deprecaation GH#34853
11871187
warnings.warn(
11881188
"to_perioddelta is deprecated and will be removed in a "
1189-
"future version. "
1190-
"Use `dtindex - dtindex.to_period(freq).to_timestamp()` instead",
1189+
"future version. "
1190+
"Use `dtindex - dtindex.to_period(freq).to_timestamp()` instead.",
11911191
FutureWarning,
11921192
# stacklevel chosen to be correct for when called from DatetimeIndex
11931193
stacklevel=3,
@@ -1353,7 +1353,7 @@ def weekofyear(self):
13531353
warnings.warn(
13541354
"weekofyear and week have been deprecated, please use "
13551355
"DatetimeIndex.isocalendar().week instead, which returns "
1356-
"a Series. To exactly reproduce the behavior of week and "
1356+
"a Series. To exactly reproduce the behavior of week and "
13571357
"weekofyear and return an Index, you may call "
13581358
"pd.Int64Index(idx.isocalendar().week)",
13591359
FutureWarning,

pandas/core/arrays/sparse/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def __init__(
407407
if is_datetime64tz_dtype(data.dtype):
408408
warnings.warn(
409409
f"Creating SparseArray from {data.dtype} data "
410-
"loses timezone information. Cast to object before "
410+
"loses timezone information. Cast to object before "
411411
"sparse to retain timezone information.",
412412
UserWarning,
413413
stacklevel=2,

pandas/core/computation/align.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _align_core(terms):
124124
w = (
125125
f"Alignment difference on axis {axis} is larger "
126126
f"than an order of magnitude on term {repr(terms[i].name)}, "
127-
f"by more than {ordm:.4g}; performance may suffer"
127+
f"by more than {ordm:.4g}; performance may suffer."
128128
)
129129
warnings.warn(w, category=PerformanceWarning, stacklevel=6)
130130

pandas/core/computation/expressions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def _bool_arith_fallback(op_str, a, b):
214214
warnings.warn(
215215
f"evaluating in Python space because the {repr(op_str)} "
216216
"operator is not supported by numexpr for the bool dtype, "
217-
f"use {repr(_BOOL_OP_UNSUPPORTED[op_str])} instead"
217+
f"use {repr(_BOOL_OP_UNSUPPORTED[op_str])} instead."
218218
)
219219
return True
220220
return False

pandas/core/construction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def _try_cast(
767767
f"Could not cast to {dtype}, falling back to object. This "
768768
"behavior is deprecated. In a future version, when a dtype is "
769769
"passed to 'DataFrame', either all columns will be cast to that "
770-
"dtype, or a TypeError will be raised",
770+
"dtype, or a TypeError will be raised.",
771771
FutureWarning,
772772
stacklevel=7,
773773
)

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ def maybe_cast_to_integer_array(
20852085
warnings.warn(
20862086
f"Constructing Series or DataFrame from {arr.dtype} values and "
20872087
f"dtype={dtype} is deprecated and will raise in a future version. "
2088-
"Use values.view(dtype) instead",
2088+
"Use values.view(dtype) instead.",
20892089
FutureWarning,
20902090
stacklevel=find_stack_level(),
20912091
)

pandas/core/dtypes/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ def is_categorical(arr) -> bool:
302302
True
303303
"""
304304
warnings.warn(
305-
"is_categorical is deprecated and will be removed in a future version. "
306-
"Use is_categorical_dtype instead",
305+
"is_categorical is deprecated and will be removed in a future version. "
306+
"Use is_categorical_dtype instead.",
307307
FutureWarning,
308308
stacklevel=2,
309309
)

pandas/core/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4542,9 +4542,9 @@ def lookup(
45424542
The found values.
45434543
"""
45444544
msg = (
4545-
"The 'lookup' method is deprecated and will be"
4546-
"removed in a future version."
4547-
"You can use DataFrame.melt and DataFrame.loc"
4545+
"The 'lookup' method is deprecated and will be "
4546+
"removed in a future version. "
4547+
"You can use DataFrame.melt and DataFrame.loc "
45484548
"as a substitute."
45494549
)
45504550
warnings.warn(msg, FutureWarning, stacklevel=2)

pandas/core/generic.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8970,7 +8970,7 @@ def where(
89708970
if try_cast is not lib.no_default:
89718971
warnings.warn(
89728972
"try_cast keyword is deprecated and will be removed in a "
8973-
"future version",
8973+
"future version.",
89748974
FutureWarning,
89758975
stacklevel=4,
89768976
)
@@ -9003,7 +9003,7 @@ def mask(
90039003
if try_cast is not lib.no_default:
90049004
warnings.warn(
90059005
"try_cast keyword is deprecated and will be removed in a "
9006-
"future version",
9006+
"future version.",
90079007
FutureWarning,
90089008
stacklevel=4,
90099009
)
@@ -9196,7 +9196,7 @@ def slice_shift(self: FrameOrSeries, periods: int = 1, axis=0) -> FrameOrSeries:
91969196
msg = (
91979197
"The 'slice_shift' method is deprecated "
91989198
"and will be removed in a future version. "
9199-
"You can use DataFrame/Series.shift instead"
9199+
"You can use DataFrame/Series.shift instead."
92009200
)
92019201
warnings.warn(msg, FutureWarning, stacklevel=2)
92029202

@@ -10838,7 +10838,7 @@ def expanding(
1083810838
axis = self._get_axis_number(axis)
1083910839
if center is not None:
1084010840
warnings.warn(
10841-
"The `center` argument on `expanding` will be removed in the future",
10841+
"The `center` argument on `expanding` will be removed in the future.",
1084210842
FutureWarning,
1084310843
stacklevel=2,
1084410844
)

pandas/core/index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# GH#30193
2525
warnings.warn(
26-
"pandas.core.index is deprecated and will be removed in a future version. "
26+
"pandas.core.index is deprecated and will be removed in a future version. "
2727
"The public classes are available in the top-level namespace.",
2828
FutureWarning,
2929
stacklevel=2,

pandas/core/indexes/accessors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def weekofyear(self):
283283
Please use Series.dt.isocalendar().week instead.
284284
"""
285285
warnings.warn(
286-
"Series.dt.weekofyear and Series.dt.week have been deprecated. "
286+
"Series.dt.weekofyear and Series.dt.week have been deprecated. "
287287
"Please use Series.dt.isocalendar().week instead.",
288288
FutureWarning,
289289
stacklevel=2,

pandas/core/indexes/base.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def __new__(
387387
warnings.warn(
388388
"Passing keywords other than 'data', 'dtype', 'copy', 'name', "
389389
"'tupleize_cols' is deprecated and will raise TypeError in a "
390-
"future version. Use the specific Index subclass directly instead",
390+
"future version. Use the specific Index subclass directly instead.",
391391
FutureWarning,
392392
stacklevel=2,
393393
)
@@ -620,7 +620,7 @@ def asi8(self):
620620
An ndarray with int64 dtype.
621621
"""
622622
warnings.warn(
623-
"Index.asi8 is deprecated and will be removed in a future version",
623+
"Index.asi8 is deprecated and will be removed in a future version.",
624624
FutureWarning,
625625
stacklevel=2,
626626
)
@@ -2469,8 +2469,8 @@ def is_all_dates(self) -> bool:
24692469
Whether or not the index values only consist of dates.
24702470
"""
24712471
warnings.warn(
2472-
"Index.is_all_dates is deprecated, will be removed in a future version. "
2473-
"check index.inferred_type instead",
2472+
"Index.is_all_dates is deprecated, will be removed in a future version. "
2473+
"check index.inferred_type instead.",
24742474
FutureWarning,
24752475
stacklevel=2,
24762476
)
@@ -2835,7 +2835,7 @@ def __and__(self, other):
28352835
warnings.warn(
28362836
"Index.__and__ operating as a set operation is deprecated, "
28372837
"in the future this will be a logical operation matching "
2838-
"Series.__and__. Use index.intersection(other) instead",
2838+
"Series.__and__. Use index.intersection(other) instead.",
28392839
FutureWarning,
28402840
stacklevel=2,
28412841
)
@@ -2846,7 +2846,7 @@ def __or__(self, other):
28462846
warnings.warn(
28472847
"Index.__or__ operating as a set operation is deprecated, "
28482848
"in the future this will be a logical operation matching "
2849-
"Series.__or__. Use index.union(other) instead",
2849+
"Series.__or__. Use index.union(other) instead.",
28502850
FutureWarning,
28512851
stacklevel=2,
28522852
)
@@ -2857,7 +2857,7 @@ def __xor__(self, other):
28572857
warnings.warn(
28582858
"Index.__xor__ operating as a set operation is deprecated, "
28592859
"in the future this will be a logical operation matching "
2860-
"Series.__xor__. Use index.symmetric_difference(other) instead",
2860+
"Series.__xor__. Use index.symmetric_difference(other) instead.",
28612861
FutureWarning,
28622862
stacklevel=2,
28632863
)
@@ -3455,7 +3455,7 @@ def get_loc(self, key, method=None, tolerance=None):
34553455
warnings.warn(
34563456
f"Passing method to {type(self).__name__}.get_loc is deprecated "
34573457
"and will raise in a future version. Use "
3458-
"index.get_indexer([item], method=...) instead",
3458+
"index.get_indexer([item], method=...) instead.",
34593459
FutureWarning,
34603460
stacklevel=2,
34613461
)
@@ -3964,7 +3964,7 @@ def reindex(
39643964
# GH#42568
39653965
warnings.warn(
39663966
"reindexing with a non-unique Index is deprecated and "
3967-
"will raise in a future version",
3967+
"will raise in a future version.",
39683968
FutureWarning,
39693969
stacklevel=2,
39703970
)
@@ -4695,7 +4695,7 @@ def is_type_compatible(self, kind: str_t) -> bool:
46954695
"""
46964696
warnings.warn(
46974697
"Index.is_type_compatible is deprecated and will be removed in a "
4698-
"future version",
4698+
"future version.",
46994699
FutureWarning,
47004700
stacklevel=2,
47014701
)
@@ -5311,7 +5311,7 @@ def get_value(self, series: Series, key):
53115311
"""
53125312
warnings.warn(
53135313
"get_value is deprecated and will be removed in a future version. "
5314-
"Use Series[key] instead",
5314+
"Use Series[key] instead.",
53155315
FutureWarning,
53165316
stacklevel=2,
53175317
)
@@ -6861,7 +6861,7 @@ def _maybe_try_sort(result, sort):
68616861
result = algos.safe_sort(result)
68626862
except TypeError as err:
68636863
warnings.warn(
6864-
f"{err}, sort order is undefined for incomparable objects",
6864+
f"{err}, sort order is undefined for incomparable objects.",
68656865
RuntimeWarning,
68666866
stacklevel=4,
68676867
)

pandas/core/indexes/category.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def __new__(
216216
warnings.warn(
217217
"Constructing a CategoricalIndex without passing data is "
218218
"deprecated and will raise in a future version. "
219-
"Use CategoricalIndex([], ...) instead",
219+
"Use CategoricalIndex([], ...) instead.",
220220
FutureWarning,
221221
stacklevel=2,
222222
)
@@ -430,7 +430,7 @@ def reindex(
430430
# GH#42568
431431
warnings.warn(
432432
"reindexing with a non-unique Index is deprecated and will "
433-
"raise in a future version",
433+
"raise in a future version.",
434434
FutureWarning,
435435
stacklevel=2,
436436
)
@@ -504,7 +504,8 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:
504504
def take_nd(self, *args, **kwargs):
505505
"""Alias for `take`"""
506506
warnings.warn(
507-
"CategoricalIndex.take_nd is deprecated, use CategoricalIndex.take instead",
507+
"CategoricalIndex.take_nd is deprecated, use CategoricalIndex.take "
508+
"instead.",
508509
FutureWarning,
509510
stacklevel=2,
510511
)

pandas/core/indexes/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def _has_complex_internals(self) -> bool:
556556
def is_type_compatible(self, kind: str) -> bool:
557557
warnings.warn(
558558
f"{type(self).__name__}.is_type_compatible is deprecated and will be "
559-
"removed in a future version",
559+
"removed in a future version.",
560560
FutureWarning,
561561
stacklevel=2,
562562
)

0 commit comments

Comments
 (0)