diff --git a/pandas/__init__.py b/pandas/__init__.py index 82593a932d0dd..68ca20338e99b 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -207,7 +207,7 @@ def __getattr__(name): warnings.warn( "The pandas.np module is deprecated " "and will be removed from pandas in a future version. " - "Import numpy directly instead", + "Import numpy directly instead.", FutureWarning, stacklevel=2, ) @@ -218,7 +218,7 @@ def __getattr__(name): elif name in {"SparseSeries", "SparseDataFrame"}: warnings.warn( f"The {name} class is removed from pandas. Accessing it from " - "the top-level namespace will also be removed in the next version", + "the top-level namespace will also be removed in the next version.", FutureWarning, stacklevel=2, ) diff --git a/pandas/_libs/parsers.pyx b/pandas/_libs/parsers.pyx index 25028b06f7bad..0c3918044a374 100644 --- a/pandas/_libs/parsers.pyx +++ b/pandas/_libs/parsers.pyx @@ -1000,7 +1000,7 @@ cdef class TextReader: if col_dtype is not None: warnings.warn((f"Both a converter and dtype were specified " f"for column {name} - only the converter will " - f"be used"), ParserWarning, + f"be used."), ParserWarning, stacklevel=5) results[i] = _apply_converter(conv, self.parser, i, start, end) continue diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 268cdb80c22f3..4ff6be25127c8 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -143,7 +143,7 @@ cdef class _NaT(datetime): return True warnings.warn( "Comparison of NaT with datetime.date is deprecated in " - "order to match the standard library behavior. " + "order to match the standard library behavior. " "In a future version these will be considered non-comparable.", FutureWarning, stacklevel=1, diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index bb9d199023e9a..4c9b681452c0a 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -696,7 +696,7 @@ cdef class BaseOffset: def onOffset(self, dt) -> bool: warnings.warn( - "onOffset is a deprecated, use is_on_offset instead", + "onOffset is a deprecated, use is_on_offset instead.", FutureWarning, stacklevel=1, ) @@ -704,7 +704,7 @@ cdef class BaseOffset: def isAnchored(self) -> bool: warnings.warn( - "isAnchored is a deprecated, use is_anchored instead", + "isAnchored is a deprecated, use is_anchored instead.", FutureWarning, stacklevel=1, ) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 59b62849484a6..43f9be3fef5ee 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -571,7 +571,7 @@ cdef inline timedelta_from_spec(object number, object frac, object unit): if unit in ["M", "Y", "y"]: warnings.warn( "Units 'M', 'Y' and 'y' do not represent unambiguous " - "timedelta values and will be removed in a future version", + "timedelta values and will be removed in a future version.", FutureWarning, stacklevel=2, ) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 5a3a95384e731..1094fac6d8504 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -171,7 +171,7 @@ cdef class _Timestamp(ABCTimestamp): @property def freq(self): warnings.warn( - "Timestamp.freq is deprecated and will be removed in a future version", + "Timestamp.freq is deprecated and will be removed in a future version.", FutureWarning, stacklevel=1, ) @@ -235,8 +235,8 @@ cdef class _Timestamp(ABCTimestamp): # We follow the stdlib datetime behavior of never being equal warnings.warn( "Comparison of Timestamp with datetime.date is deprecated in " - "order to match the standard library behavior. " - "In a future version these will be considered non-comparable." + "order to match the standard library behavior. " + "In a future version these will be considered non-comparable. " "Use 'ts == pd.Timestamp(date)' or 'ts.date() == date' instead.", FutureWarning, stacklevel=1, @@ -425,7 +425,7 @@ cdef class _Timestamp(ABCTimestamp): warnings.warn( "Timestamp.freq is deprecated and will be removed in a future " "version. When you have a freq, use " - f"freq.{field}(timestamp) instead", + f"freq.{field}(timestamp) instead.", FutureWarning, stacklevel=1, ) @@ -858,7 +858,7 @@ cdef class _Timestamp(ABCTimestamp): NaT """ if self.nanosecond != 0 and warn: - warnings.warn("Discarding nonzero nanoseconds in conversion", + warnings.warn("Discarding nonzero nanoseconds in conversion.", UserWarning, stacklevel=2) return datetime(self.year, self.month, self.day, diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 8b5bda4629506..3402b9594e6dd 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1186,7 +1186,7 @@ def _addsub_object_array(self, other: np.ndarray, op): warnings.warn( "Adding/subtracting object-dtype array to " - f"{type(self).__name__} not vectorized", + f"{type(self).__name__} not vectorized.", PerformanceWarning, ) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 8513bbb044e83..17461ad95866e 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -744,7 +744,7 @@ def _add_offset(self, offset) -> DatetimeArray: except NotImplementedError: warnings.warn( - "Non-vectorized DateOffset being applied to Series or DatetimeIndex", + "Non-vectorized DateOffset being applied to Series or DatetimeIndex.", PerformanceWarning, ) result = self.astype("O") + offset @@ -1186,8 +1186,8 @@ def to_perioddelta(self, freq) -> TimedeltaArray: # Deprecaation GH#34853 warnings.warn( "to_perioddelta is deprecated and will be removed in a " - "future version. " - "Use `dtindex - dtindex.to_period(freq).to_timestamp()` instead", + "future version. " + "Use `dtindex - dtindex.to_period(freq).to_timestamp()` instead.", FutureWarning, # stacklevel chosen to be correct for when called from DatetimeIndex stacklevel=3, @@ -1353,7 +1353,7 @@ def weekofyear(self): warnings.warn( "weekofyear and week have been deprecated, please use " "DatetimeIndex.isocalendar().week instead, which returns " - "a Series. To exactly reproduce the behavior of week and " + "a Series. To exactly reproduce the behavior of week and " "weekofyear and return an Index, you may call " "pd.Int64Index(idx.isocalendar().week)", FutureWarning, diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index b1cfcbd69a30b..68c9e42ef8e08 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -407,7 +407,7 @@ def __init__( if is_datetime64tz_dtype(data.dtype): warnings.warn( f"Creating SparseArray from {data.dtype} data " - "loses timezone information. Cast to object before " + "loses timezone information. Cast to object before " "sparse to retain timezone information.", UserWarning, stacklevel=2, diff --git a/pandas/core/computation/align.py b/pandas/core/computation/align.py index 8217dbfbda655..148b37cafbf78 100644 --- a/pandas/core/computation/align.py +++ b/pandas/core/computation/align.py @@ -124,7 +124,7 @@ def _align_core(terms): w = ( f"Alignment difference on axis {axis} is larger " f"than an order of magnitude on term {repr(terms[i].name)}, " - f"by more than {ordm:.4g}; performance may suffer" + f"by more than {ordm:.4g}; performance may suffer." ) warnings.warn(w, category=PerformanceWarning, stacklevel=6) diff --git a/pandas/core/computation/expressions.py b/pandas/core/computation/expressions.py index a62137bd63692..7b5f5cafb26f4 100644 --- a/pandas/core/computation/expressions.py +++ b/pandas/core/computation/expressions.py @@ -214,7 +214,7 @@ def _bool_arith_fallback(op_str, a, b): warnings.warn( f"evaluating in Python space because the {repr(op_str)} " "operator is not supported by numexpr for the bool dtype, " - f"use {repr(_BOOL_OP_UNSUPPORTED[op_str])} instead" + f"use {repr(_BOOL_OP_UNSUPPORTED[op_str])} instead." ) return True return False diff --git a/pandas/core/construction.py b/pandas/core/construction.py index 7215cd17409cb..90349ee5f942f 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -767,7 +767,7 @@ def _try_cast( f"Could not cast to {dtype}, falling back to object. This " "behavior is deprecated. In a future version, when a dtype is " "passed to 'DataFrame', either all columns will be cast to that " - "dtype, or a TypeError will be raised", + "dtype, or a TypeError will be raised.", FutureWarning, stacklevel=7, ) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 4f4276ceddcf9..6f10a490c7147 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -2085,7 +2085,7 @@ def maybe_cast_to_integer_array( warnings.warn( f"Constructing Series or DataFrame from {arr.dtype} values and " f"dtype={dtype} is deprecated and will raise in a future version. " - "Use values.view(dtype) instead", + "Use values.view(dtype) instead.", FutureWarning, stacklevel=find_stack_level(), ) diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 069d7d8c76efb..393fe08f7277c 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -302,8 +302,8 @@ def is_categorical(arr) -> bool: True """ warnings.warn( - "is_categorical is deprecated and will be removed in a future version. " - "Use is_categorical_dtype instead", + "is_categorical is deprecated and will be removed in a future version. " + "Use is_categorical_dtype instead.", FutureWarning, stacklevel=2, ) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 304e350a377bb..e02a88aafcf34 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4542,9 +4542,9 @@ def lookup( The found values. """ msg = ( - "The 'lookup' method is deprecated and will be" - "removed in a future version." - "You can use DataFrame.melt and DataFrame.loc" + "The 'lookup' method is deprecated and will be " + "removed in a future version. " + "You can use DataFrame.melt and DataFrame.loc " "as a substitute." ) warnings.warn(msg, FutureWarning, stacklevel=2) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 36c0d024369e6..bace333c9ccb5 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8970,7 +8970,7 @@ def where( if try_cast is not lib.no_default: warnings.warn( "try_cast keyword is deprecated and will be removed in a " - "future version", + "future version.", FutureWarning, stacklevel=4, ) @@ -9003,7 +9003,7 @@ def mask( if try_cast is not lib.no_default: warnings.warn( "try_cast keyword is deprecated and will be removed in a " - "future version", + "future version.", FutureWarning, stacklevel=4, ) @@ -9196,7 +9196,7 @@ def slice_shift(self: FrameOrSeries, periods: int = 1, axis=0) -> FrameOrSeries: msg = ( "The 'slice_shift' method is deprecated " "and will be removed in a future version. " - "You can use DataFrame/Series.shift instead" + "You can use DataFrame/Series.shift instead." ) warnings.warn(msg, FutureWarning, stacklevel=2) @@ -10838,7 +10838,7 @@ def expanding( axis = self._get_axis_number(axis) if center is not None: warnings.warn( - "The `center` argument on `expanding` will be removed in the future", + "The `center` argument on `expanding` will be removed in the future.", FutureWarning, stacklevel=2, ) diff --git a/pandas/core/index.py b/pandas/core/index.py index 44f434e038a4b..13a687b1c27e3 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -23,7 +23,7 @@ # GH#30193 warnings.warn( - "pandas.core.index is deprecated and will be removed in a future version. " + "pandas.core.index is deprecated and will be removed in a future version. " "The public classes are available in the top-level namespace.", FutureWarning, stacklevel=2, diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 017f58bff03e9..516c63e0e3727 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -283,7 +283,7 @@ def weekofyear(self): Please use Series.dt.isocalendar().week instead. """ warnings.warn( - "Series.dt.weekofyear and Series.dt.week have been deprecated. " + "Series.dt.weekofyear and Series.dt.week have been deprecated. " "Please use Series.dt.isocalendar().week instead.", FutureWarning, stacklevel=2, diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 8c32ccc1fa74c..2615bfffb3cd9 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -387,7 +387,7 @@ def __new__( warnings.warn( "Passing keywords other than 'data', 'dtype', 'copy', 'name', " "'tupleize_cols' is deprecated and will raise TypeError in a " - "future version. Use the specific Index subclass directly instead", + "future version. Use the specific Index subclass directly instead.", FutureWarning, stacklevel=2, ) @@ -620,7 +620,7 @@ def asi8(self): An ndarray with int64 dtype. """ warnings.warn( - "Index.asi8 is deprecated and will be removed in a future version", + "Index.asi8 is deprecated and will be removed in a future version.", FutureWarning, stacklevel=2, ) @@ -2469,8 +2469,8 @@ def is_all_dates(self) -> bool: Whether or not the index values only consist of dates. """ warnings.warn( - "Index.is_all_dates is deprecated, will be removed in a future version. " - "check index.inferred_type instead", + "Index.is_all_dates is deprecated, will be removed in a future version. " + "check index.inferred_type instead.", FutureWarning, stacklevel=2, ) @@ -2835,7 +2835,7 @@ def __and__(self, other): warnings.warn( "Index.__and__ operating as a set operation is deprecated, " "in the future this will be a logical operation matching " - "Series.__and__. Use index.intersection(other) instead", + "Series.__and__. Use index.intersection(other) instead.", FutureWarning, stacklevel=2, ) @@ -2846,7 +2846,7 @@ def __or__(self, other): warnings.warn( "Index.__or__ operating as a set operation is deprecated, " "in the future this will be a logical operation matching " - "Series.__or__. Use index.union(other) instead", + "Series.__or__. Use index.union(other) instead.", FutureWarning, stacklevel=2, ) @@ -2857,7 +2857,7 @@ def __xor__(self, other): warnings.warn( "Index.__xor__ operating as a set operation is deprecated, " "in the future this will be a logical operation matching " - "Series.__xor__. Use index.symmetric_difference(other) instead", + "Series.__xor__. Use index.symmetric_difference(other) instead.", FutureWarning, stacklevel=2, ) @@ -3455,7 +3455,7 @@ def get_loc(self, key, method=None, tolerance=None): warnings.warn( f"Passing method to {type(self).__name__}.get_loc is deprecated " "and will raise in a future version. Use " - "index.get_indexer([item], method=...) instead", + "index.get_indexer([item], method=...) instead.", FutureWarning, stacklevel=2, ) @@ -3964,7 +3964,7 @@ def reindex( # GH#42568 warnings.warn( "reindexing with a non-unique Index is deprecated and " - "will raise in a future version", + "will raise in a future version.", FutureWarning, stacklevel=2, ) @@ -4695,7 +4695,7 @@ def is_type_compatible(self, kind: str_t) -> bool: """ warnings.warn( "Index.is_type_compatible is deprecated and will be removed in a " - "future version", + "future version.", FutureWarning, stacklevel=2, ) @@ -5311,7 +5311,7 @@ def get_value(self, series: Series, key): """ warnings.warn( "get_value is deprecated and will be removed in a future version. " - "Use Series[key] instead", + "Use Series[key] instead.", FutureWarning, stacklevel=2, ) @@ -6861,7 +6861,7 @@ def _maybe_try_sort(result, sort): result = algos.safe_sort(result) except TypeError as err: warnings.warn( - f"{err}, sort order is undefined for incomparable objects", + f"{err}, sort order is undefined for incomparable objects.", RuntimeWarning, stacklevel=4, ) diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 1a6a5f08841b9..c45543a9187bd 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -216,7 +216,7 @@ def __new__( warnings.warn( "Constructing a CategoricalIndex without passing data is " "deprecated and will raise in a future version. " - "Use CategoricalIndex([], ...) instead", + "Use CategoricalIndex([], ...) instead.", FutureWarning, stacklevel=2, ) @@ -430,7 +430,7 @@ def reindex( # GH#42568 warnings.warn( "reindexing with a non-unique Index is deprecated and will " - "raise in a future version", + "raise in a future version.", FutureWarning, stacklevel=2, ) @@ -504,7 +504,8 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool: def take_nd(self, *args, **kwargs): """Alias for `take`""" warnings.warn( - "CategoricalIndex.take_nd is deprecated, use CategoricalIndex.take instead", + "CategoricalIndex.take_nd is deprecated, use CategoricalIndex.take " + "instead.", FutureWarning, stacklevel=2, ) diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index 080889444f809..5d778af954eef 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -556,7 +556,7 @@ def _has_complex_internals(self) -> bool: def is_type_compatible(self, kind: str) -> bool: warnings.warn( f"{type(self).__name__}.is_type_compatible is deprecated and will be " - "removed in a future version", + "removed in a future version.", FutureWarning, stacklevel=2, ) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index ed1a8b436792e..8a5811da4dd5a 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -496,7 +496,7 @@ def to_series(self, keep_tz=lib.no_default, index=None, name=None): if keep_tz: warnings.warn( "The 'keep_tz' keyword in DatetimeIndex.to_series " - "is deprecated and will be removed in a future version. " + "is deprecated and will be removed in a future version. " "You can stop passing 'keep_tz' to silence this warning.", FutureWarning, stacklevel=2, @@ -611,7 +611,7 @@ def _deprecate_mismatched_indexing(self, key) -> None: msg = ( "Indexing a timezone-aware DatetimeIndex with a " "timezone-naive datetime is deprecated and will " - "raise KeyError in a future version. " + "raise KeyError in a future version. " "Use a timezone-aware object instead." ) warnings.warn(msg, FutureWarning, stacklevel=find_stack_level()) diff --git a/pandas/core/indexes/numeric.py b/pandas/core/indexes/numeric.py index 08881f915ef2d..2d8948a64dde7 100644 --- a/pandas/core/indexes/numeric.py +++ b/pandas/core/indexes/numeric.py @@ -371,7 +371,7 @@ class IntegerIndex(NumericIndex): def asi8(self) -> np.ndarray: # do not cache or you'll create a memory leak warnings.warn( - "Index.asi8 is deprecated and will be removed in a future version", + "Index.asi8 is deprecated and will be removed in a future version.", FutureWarning, stacklevel=2, ) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 4e47a59740212..1d265402b040f 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -335,7 +335,7 @@ def astype(self, dtype, copy: bool = True, how=lib.no_default): warnings.warn( "The 'how' keyword in PeriodIndex.astype is deprecated and " "will be removed in a future version. " - "Use index.to_timestamp(how=how) instead", + "Use index.to_timestamp(how=how) instead.", FutureWarning, stacklevel=2, ) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index ad5f878628931..26a2996af6b2a 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -1345,7 +1345,7 @@ def _has_valid_setitem_indexer(self, indexer) -> bool: if isinstance(indexer, ABCDataFrame): warnings.warn( - "DataFrame indexer for .iloc is deprecated and will be removed in" + "DataFrame indexer for .iloc is deprecated and will be removed in " "a future version.\n" "consider using .loc with a DataFrame indexer for automatic alignment.", FutureWarning, diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 953ccedaa5222..e2680712483a4 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -190,7 +190,7 @@ def is_categorical(self) -> bool: warnings.warn( "Block.is_categorical is deprecated and will be removed in a " "future version. Use isinstance(block.values, Categorical) " - "instead. See https://github.com/pandas-dev/pandas/issues/40226", + "instead. See https://github.com/pandas-dev/pandas/issues/40226", DeprecationWarning, stacklevel=2, ) diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index d0dad26cfb275..615e0a0665d00 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -1160,7 +1160,7 @@ def insert(self, loc: int, item: Hashable, value: ArrayLike) -> None: "DataFrame is highly fragmented. This is usually the result " "of calling `frame.insert` many times, which has poor performance. " "Consider joining all columns at once using pd.concat(axis=1) " - "instead. To get a de-fragmented frame, use `newframe = frame.copy()`", + "instead. To get a de-fragmented frame, use `newframe = frame.copy()`", PerformanceWarning, stacklevel=5, ) diff --git a/pandas/core/ops/__init__.py b/pandas/core/ops/__init__.py index 297769149e5f0..ece5b21fa2f8e 100644 --- a/pandas/core/ops/__init__.py +++ b/pandas/core/ops/__init__.py @@ -296,7 +296,7 @@ def to_series(right): if not left.axes[axis].equals(right.index): warnings.warn( "Automatic reindexing on DataFrame vs Series comparisons " - "is deprecated and will raise ValueError in a future version. " + "is deprecated and will raise ValueError in a future version. " "Do `left, right = left.align(right, axis=1, copy=False)` " "before e.g. `left == right`", FutureWarning, diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index a3baf8ade9c2e..501ad383168a0 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -673,7 +673,7 @@ def __init__( if _left.columns.nlevels != _right.columns.nlevels: msg = ( "merging between different levels is deprecated and will be removed " - f"in a future version. ({left.columns.nlevels} levels on the left," + f"in a future version. ({left.columns.nlevels} levels on the left, " f"{right.columns.nlevels} on the right)" ) # stacklevel chosen to be correct when this is reached via pd.merge @@ -1201,7 +1201,7 @@ def _maybe_coerce_merge_keys(self) -> None: warnings.warn( "You are merging on int and float " "columns where the float values " - "are not equal to their int representation", + "are not equal to their int representation.", UserWarning, ) continue @@ -1211,7 +1211,7 @@ def _maybe_coerce_merge_keys(self) -> None: warnings.warn( "You are merging on int and float " "columns where the float values " - "are not equal to their int representation", + "are not equal to their int representation.", UserWarning, ) continue diff --git a/pandas/core/series.py b/pandas/core/series.py index e5e19373fcea1..a5ec4125f54a4 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5088,7 +5088,7 @@ def between(self, left, right, inclusive="both") -> Series: """ if inclusive is True or inclusive is False: warnings.warn( - "Boolean inputs to the `inclusive` argument are deprecated in" + "Boolean inputs to the `inclusive` argument are deprecated in " "favour of `both` or `neither`.", FutureWarning, stacklevel=2, diff --git a/pandas/core/tools/datetimes.py b/pandas/core/tools/datetimes.py index 8eac5f76fd455..8af0ac05157c8 100644 --- a/pandas/core/tools/datetimes.py +++ b/pandas/core/tools/datetimes.py @@ -1096,7 +1096,7 @@ def calc_with_mask(carg, mask): def to_time(arg, format=None, infer_time_format=False, errors="raise"): # GH#34145 warnings.warn( - "`to_time` has been moved, should be imported from pandas.core.tools.times. " + "`to_time` has been moved, should be imported from pandas.core.tools.times. " "This alias will be removed in a future version.", FutureWarning, stacklevel=2, diff --git a/pandas/io/clipboard/__init__.py b/pandas/io/clipboard/__init__.py index c1c9865e6721d..947deb39ae064 100644 --- a/pandas/io/clipboard/__init__.py +++ b/pandas/io/clipboard/__init__.py @@ -271,7 +271,7 @@ def copy_dev_clipboard(text): text = _stringifyText(text) # Converts non-str values to str. if text == "": warnings.warn( - "Pyperclip cannot copy a blank string to the clipboard on Cygwin." + "Pyperclip cannot copy a blank string to the clipboard on Cygwin. " "This is effectively a no-op." ) if "\r" in text: @@ -518,7 +518,7 @@ def determine_clipboard(): # see https://github.com/asweigart/pyperclip/issues/55 if os.path.exists("/dev/clipboard"): warnings.warn( - "Pyperclip's support for Cygwin is not perfect," + "Pyperclip's support for Cygwin is not perfect, " "see https://github.com/asweigart/pyperclip/issues/55" ) return init_dev_clipboard_clipboard() diff --git a/pandas/io/clipboards.py b/pandas/io/clipboards.py index a6940c08198b0..5990acd7191db 100644 --- a/pandas/io/clipboards.py +++ b/pandas/io/clipboards.py @@ -77,7 +77,7 @@ def read_clipboard(sep=r"\s+", **kwargs): # pragma: no cover kwargs["engine"] = "python" elif len(sep) > 1 and kwargs.get("engine") == "c": warnings.warn( - "read_clipboard with regex separator does not work properly with c engine" + "read_clipboard with regex separator does not work properly with c engine." ) return read_csv(StringIO(text), sep=sep, **kwargs) @@ -134,7 +134,7 @@ def to_clipboard(obj, excel=True, sep=None, **kwargs): # pragma: no cover "to_clipboard in excel mode requires a single character separator." ) elif sep is not None: - warnings.warn("to_clipboard with excel=False ignores the sep argument") + warnings.warn("to_clipboard with excel=False ignores the sep argument.") if isinstance(obj, ABCDataFrame): # str(df) has various unhelpful defaults, like truncation diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 4d6a766ad6cfa..52d1e1c83d3e6 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -504,7 +504,7 @@ def parse( else: stacklevel = find_stack_level() warnings.warn( - "convert_float is deprecated and will be removed in a future version", + "convert_float is deprecated and will be removed in a future version.", FutureWarning, stacklevel=stacklevel, ) diff --git a/pandas/io/json/_table_schema.py b/pandas/io/json/_table_schema.py index 60b2489005f48..e7a24fcee2b34 100644 --- a/pandas/io/json/_table_schema.py +++ b/pandas/io/json/_table_schema.py @@ -94,9 +94,11 @@ def set_default_names(data): if com.all_not_none(*data.index.names): nms = data.index.names if len(nms) == 1 and data.index.name == "index": - warnings.warn("Index name of 'index' is not round-trippable") + warnings.warn("Index name of 'index' is not round-trippable.") elif len(nms) > 1 and any(x.startswith("level_") for x in nms): - warnings.warn("Index names beginning with 'level_' are not round-trippable") + warnings.warn( + "Index names beginning with 'level_' are not round-trippable." + ) return data data = data.copy() diff --git a/pandas/io/parsers/base_parser.py b/pandas/io/parsers/base_parser.py index 5714bbab016c8..6737f2dfd5086 100644 --- a/pandas/io/parsers/base_parser.py +++ b/pandas/io/parsers/base_parser.py @@ -549,7 +549,7 @@ def _convert_to_ndarrays( warnings.warn( ( "Both a converter and dtype were specified " - f"for column {c} - only the converter will be used" + f"for column {c} - only the converter will be used." ), ParserWarning, stacklevel=7, diff --git a/pandas/io/parsers/c_parser_wrapper.py b/pandas/io/parsers/c_parser_wrapper.py index ae62cc3b45578..57ae61548d8d0 100644 --- a/pandas/io/parsers/c_parser_wrapper.py +++ b/pandas/io/parsers/c_parser_wrapper.py @@ -390,7 +390,7 @@ def _concatenate_chunks(chunks: list[dict[int, ArrayLike]]) -> dict: warning_names = ",".join(warning_columns) warning_message = " ".join( [ - f"Columns ({warning_names}) have mixed types." + f"Columns ({warning_names}) have mixed types. " f"Specify dtype option on import or set low_memory=False." ] ) diff --git a/pandas/io/sas/sas_xport.py b/pandas/io/sas/sas_xport.py index 6ced3febd78f4..bdb7d86a9b37e 100644 --- a/pandas/io/sas/sas_xport.py +++ b/pandas/io/sas/sas_xport.py @@ -393,7 +393,7 @@ def _record_count(self) -> int: total_records_length = self.filepath_or_buffer.tell() - self.record_start if total_records_length % 80 != 0: - warnings.warn("xport file may be corrupted") + warnings.warn("xport file may be corrupted.") if self.record_length > 80: self.filepath_or_buffer.seek(self.record_start) diff --git a/pandas/plotting/_matplotlib/tools.py b/pandas/plotting/_matplotlib/tools.py index 6d27cc8686b65..9679e79d8c4ba 100644 --- a/pandas/plotting/_matplotlib/tools.py +++ b/pandas/plotting/_matplotlib/tools.py @@ -225,12 +225,13 @@ def create_subplots( ax = flatten_axes(ax) if layout is not None: warnings.warn( - "When passing multiple axes, layout keyword is ignored", UserWarning + "When passing multiple axes, layout keyword is ignored.", + UserWarning, ) if sharex or sharey: warnings.warn( "When passing multiple axes, sharex and sharey " - "are ignored. These settings must be specified when creating axes", + "are ignored. These settings must be specified when creating axes.", UserWarning, stacklevel=4, ) @@ -253,7 +254,7 @@ def create_subplots( else: warnings.warn( "To output multiple subplots, the figure containing " - "the passed axes is being cleared", + "the passed axes is being cleared.", UserWarning, stacklevel=4, ) diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index 99c3cac9ba976..dfdb9dabf6bed 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -1110,7 +1110,7 @@ def test_performance_warning_for_poor_alignment(self, engine, parser): expected = ( f"Alignment difference on axis 1 is larger " f"than an order of magnitude on term 'df', " - f"by more than {logged:.4g}; performance may suffer" + f"by more than {logged:.4g}; performance may suffer." ) assert msg == expected diff --git a/pandas/tests/util/test_deprecate_nonkeyword_arguments.py b/pandas/tests/util/test_deprecate_nonkeyword_arguments.py index a20264ac6fbb0..c03639811d9d5 100644 --- a/pandas/tests/util/test_deprecate_nonkeyword_arguments.py +++ b/pandas/tests/util/test_deprecate_nonkeyword_arguments.py @@ -69,7 +69,7 @@ def test_three_positional_argument_with_warning_message_analysis(): assert actual_warning.category == FutureWarning assert str(actual_warning.message) == ( "Starting with pandas version 1.1 all arguments of g " - "except for the argument 'a' will be keyword-only" + "except for the argument 'a' will be keyword-only." ) @@ -97,7 +97,7 @@ def test_one_positional_argument_with_warning_message_analysis(): assert actual_warning.category == FutureWarning assert str(actual_warning.message) == ( "Starting with pandas version 1.1 all arguments " - "of h will be keyword-only" + "of h will be keyword-only." ) diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index c55ac6ce228bf..b4d847901613a 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -113,7 +113,7 @@ def get_offset(name: str) -> DateOffset: """ warnings.warn( "get_offset is deprecated and will be removed in a future version, " - "use to_offset instead", + "use to_offset instead.", FutureWarning, stacklevel=2, ) diff --git a/pandas/util/_decorators.py b/pandas/util/_decorators.py index c540c0e1c6721..d98b0d24d22b9 100644 --- a/pandas/util/_decorators.py +++ b/pandas/util/_decorators.py @@ -51,7 +51,7 @@ def deprecate( """ alt_name = alt_name or alternative.__name__ klass = klass or FutureWarning - warning_msg = msg or f"{name} is deprecated, use {alt_name} instead" + warning_msg = msg or f"{name} is deprecated, use {alt_name} instead." @wraps(alternative) def wrapper(*args, **kwargs) -> Callable[..., Any]: @@ -186,20 +186,20 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]: msg = ( f"the {old_arg_name}={repr(old_arg_value)} keyword is " "deprecated, use " - f"{new_arg_name}={repr(new_arg_value)} instead" + f"{new_arg_name}={repr(new_arg_value)} instead." ) else: new_arg_value = old_arg_value msg = ( f"the {repr(old_arg_name)}' keyword is deprecated, " - f"use {repr(new_arg_name)} instead" + f"use {repr(new_arg_name)} instead." ) warnings.warn(msg, FutureWarning, stacklevel=stacklevel) if kwargs.get(new_arg_name) is not None: msg = ( f"Can only specify {repr(old_arg_name)} " - f"or {repr(new_arg_name)}, not both" + f"or {repr(new_arg_name)}, not both." ) raise TypeError(msg) else: @@ -296,7 +296,7 @@ def decorate(func): num_allow_args = len(allow_args) msg = ( f"{future_version_msg(version)} all arguments of " - f"{func.__qualname__}{{arguments}} will be keyword-only" + f"{func.__qualname__}{{arguments}} will be keyword-only." ) @wraps(func) diff --git a/pandas/util/version/__init__.py b/pandas/util/version/__init__.py index cd6a38f9e7ff1..a6eccf2941342 100644 --- a/pandas/util/version/__init__.py +++ b/pandas/util/version/__init__.py @@ -185,7 +185,7 @@ def __init__(self, version: str) -> None: warnings.warn( "Creating a LegacyVersion has been deprecated and will be " - "removed in the next major release", + "removed in the next major release.", DeprecationWarning, )