diff --git a/py-polars/docs/source/reference/dataframe/group_by.rst b/py-polars/docs/source/reference/dataframe/group_by.rst
index 64f625644262c..459abd6419b72 100644
--- a/py-polars/docs/source/reference/dataframe/group_by.rst
+++ b/py-polars/docs/source/reference/dataframe/group_by.rst
@@ -11,7 +11,6 @@ This namespace is available after calling :code:`DataFrame.group_by(...)`.
GroupBy.__iter__
GroupBy.agg
GroupBy.all
- GroupBy.apply
GroupBy.count
GroupBy.first
GroupBy.head
diff --git a/py-polars/docs/source/reference/dataframe/miscellaneous.rst b/py-polars/docs/source/reference/dataframe/miscellaneous.rst
index d74d24d20288c..6e89f4cd1249c 100644
--- a/py-polars/docs/source/reference/dataframe/miscellaneous.rst
+++ b/py-polars/docs/source/reference/dataframe/miscellaneous.rst
@@ -6,10 +6,8 @@ Miscellaneous
.. autosummary::
:toctree: api/
- DataFrame.apply
DataFrame.corr
DataFrame.equals
- DataFrame.frame_equal
DataFrame.lazy
DataFrame.map_rows
diff --git a/py-polars/docs/source/reference/dataframe/modify_select.rst b/py-polars/docs/source/reference/dataframe/modify_select.rst
index 17a1b60cbde4e..26cb474f7c638 100644
--- a/py-polars/docs/source/reference/dataframe/modify_select.rst
+++ b/py-polars/docs/source/reference/dataframe/modify_select.rst
@@ -18,20 +18,14 @@ Manipulation/selection
DataFrame.fill_nan
DataFrame.fill_null
DataFrame.filter
- DataFrame.find_idx_by_name
DataFrame.gather_every
DataFrame.get_column
DataFrame.get_column_index
DataFrame.get_columns
DataFrame.group_by
DataFrame.group_by_dynamic
- DataFrame.group_by_rolling
- DataFrame.groupby
- DataFrame.groupby_dynamic
- DataFrame.groupby_rolling
DataFrame.head
DataFrame.hstack
- DataFrame.insert_at_idx
DataFrame.insert_column
DataFrame.interpolate
DataFrame.item
@@ -48,8 +42,6 @@ Manipulation/selection
DataFrame.pivot
DataFrame.rechunk
DataFrame.rename
- DataFrame.replace
- DataFrame.replace_at_idx
DataFrame.replace_column
DataFrame.reverse
DataFrame.rolling
@@ -61,13 +53,11 @@ Manipulation/selection
DataFrame.select_seq
DataFrame.set_sorted
DataFrame.shift
- DataFrame.shift_and_fill
DataFrame.shrink_to_fit
DataFrame.slice
DataFrame.sort
DataFrame.sql
DataFrame.tail
- DataFrame.take_every
DataFrame.to_dummies
DataFrame.to_series
DataFrame.top_k
diff --git a/py-polars/docs/source/reference/expressions/boolean.rst b/py-polars/docs/source/reference/expressions/boolean.rst
index a3fee0bdfdae8..f70e93d588f94 100644
--- a/py-polars/docs/source/reference/expressions/boolean.rst
+++ b/py-polars/docs/source/reference/expressions/boolean.rst
@@ -12,14 +12,11 @@ Boolean
Expr.is_between
Expr.is_duplicated
Expr.is_finite
- Expr.is_first
Expr.is_first_distinct
Expr.is_in
Expr.is_infinite
- Expr.is_last
Expr.is_last_distinct
Expr.is_nan
- Expr.is_not
Expr.is_not_nan
Expr.is_not_null
Expr.is_null
diff --git a/py-polars/docs/source/reference/expressions/categories.rst b/py-polars/docs/source/reference/expressions/categories.rst
index cd99c9a91d7a2..160b1f456b293 100644
--- a/py-polars/docs/source/reference/expressions/categories.rst
+++ b/py-polars/docs/source/reference/expressions/categories.rst
@@ -10,4 +10,3 @@ The following methods are available under the `expr.cat` attribute.
:template: autosummary/accessor_method.rst
Expr.cat.get_categories
- Expr.cat.set_ordering
diff --git a/py-polars/docs/source/reference/expressions/columns.rst b/py-polars/docs/source/reference/expressions/columns.rst
index c97e3cf13f253..1fdf2ccbc86bc 100644
--- a/py-polars/docs/source/reference/expressions/columns.rst
+++ b/py-polars/docs/source/reference/expressions/columns.rst
@@ -8,10 +8,6 @@ Columns / names
Expr.alias
Expr.exclude
- Expr.keep_name
- Expr.map_alias
- Expr.prefix
- Expr.suffix
.. toctree::
:maxdepth: 2
diff --git a/py-polars/docs/source/reference/expressions/computation.rst b/py-polars/docs/source/reference/expressions/computation.rst
index 34fb8aa383410..6f90e9c1eab2a 100644
--- a/py-polars/docs/source/reference/expressions/computation.rst
+++ b/py-polars/docs/source/reference/expressions/computation.rst
@@ -24,11 +24,6 @@ Computation
Expr.cum_min
Expr.cum_prod
Expr.cum_sum
- Expr.cumcount
- Expr.cummax
- Expr.cummin
- Expr.cumprod
- Expr.cumsum
Expr.cumulative_eval
Expr.degrees
Expr.diff
@@ -53,7 +48,6 @@ Computation
Expr.peak_min
Expr.radians
Expr.rank
- Expr.rolling_apply
Expr.rolling_map
Expr.rolling_max
Expr.rolling_max_by
diff --git a/py-polars/docs/source/reference/expressions/functions.rst b/py-polars/docs/source/reference/expressions/functions.rst
index 78d2532e1be18..4a8ca0425fca2 100644
--- a/py-polars/docs/source/reference/expressions/functions.rst
+++ b/py-polars/docs/source/reference/expressions/functions.rst
@@ -16,7 +16,6 @@ These functions are available from the Polars module root and can be used as exp
all_horizontal
any
any_horizontal
- apply
approx_n_unique
arange
arctan2
@@ -35,10 +34,6 @@ These functions are available from the Polars module root and can be used as exp
cum_reduce
cum_sum
cum_sum_horizontal
- cumfold
- cumreduce
- cumsum
- cumsum_horizontal
date
datetime
date_range
@@ -60,7 +55,6 @@ These functions are available from the Polars module root and can be used as exp
last
len
lit
- map
map_batches
map_groups
max
@@ -101,15 +95,12 @@ These functions are available from the Polars module root and can be used as exp
Expr.all
Expr.any
- Expr.apply
Expr.approx_n_unique
Expr.count
- Expr.cumsum
Expr.exclude
Expr.first
Expr.head
Expr.implode
- Expr.map
Expr.map_batches
Expr.map_elements
Expr.max
diff --git a/py-polars/docs/source/reference/expressions/list.rst b/py-polars/docs/source/reference/expressions/list.rst
index d168e3976f025..7d330772511d8 100644
--- a/py-polars/docs/source/reference/expressions/list.rst
+++ b/py-polars/docs/source/reference/expressions/list.rst
@@ -16,7 +16,6 @@ The following methods are available under the `expr.list` attribute.
Expr.list.arg_min
Expr.list.concat
Expr.list.contains
- Expr.list.count_match
Expr.list.count_matches
Expr.list.diff
Expr.list.eval
@@ -28,7 +27,6 @@ The following methods are available under the `expr.list` attribute.
Expr.list.join
Expr.list.last
Expr.list.len
- Expr.list.lengths
Expr.list.max
Expr.list.mean
Expr.list.median
@@ -45,7 +43,6 @@ The following methods are available under the `expr.list` attribute.
Expr.list.std
Expr.list.sum
Expr.list.tail
- Expr.list.take
Expr.list.to_array
Expr.list.to_struct
Expr.list.unique
diff --git a/py-polars/docs/source/reference/expressions/modify_select.rst b/py-polars/docs/source/reference/expressions/modify_select.rst
index 31e82ba56fc2c..53437ea96fc9c 100644
--- a/py-polars/docs/source/reference/expressions/modify_select.rst
+++ b/py-polars/docs/source/reference/expressions/modify_select.rst
@@ -15,8 +15,6 @@ Manipulation/selection
Expr.cast
Expr.ceil
Expr.clip
- Expr.clip_max
- Expr.clip_min
Expr.cut
Expr.drop_nans
Expr.drop_nulls
@@ -37,7 +35,6 @@ Manipulation/selection
Expr.interpolate_by
Expr.limit
Expr.lower_bound
- Expr.map_dict
Expr.pipe
Expr.qcut
Expr.rechunk
@@ -52,15 +49,12 @@ Manipulation/selection
Expr.round_sig_figs
Expr.sample
Expr.shift
- Expr.shift_and_fill
Expr.shrink_dtype
Expr.shuffle
Expr.slice
Expr.sort
Expr.sort_by
Expr.tail
- Expr.take
- Expr.take_every
Expr.to_physical
Expr.top_k
Expr.top_k_by
diff --git a/py-polars/docs/source/reference/expressions/string.rst b/py-polars/docs/source/reference/expressions/string.rst
index 1b4159814b817..b61cb0c3f035d 100644
--- a/py-polars/docs/source/reference/expressions/string.rst
+++ b/py-polars/docs/source/reference/expressions/string.rst
@@ -12,7 +12,6 @@ The following methods are available under the `expr.str` attribute.
Expr.str.concat
Expr.str.contains
Expr.str.contains_any
- Expr.str.count_match
Expr.str.count_matches
Expr.str.decode
Expr.str.encode
@@ -24,29 +23,20 @@ The following methods are available under the `expr.str` attribute.
Expr.str.find
Expr.str.head
Expr.str.json_decode
- Expr.str.json_extract
Expr.str.json_path_match
Expr.str.len_bytes
Expr.str.len_chars
- Expr.str.lengths
- Expr.str.ljust
- Expr.str.lstrip
- Expr.str.n_chars
Expr.str.pad_end
Expr.str.pad_start
- Expr.str.parse_int
Expr.str.replace
Expr.str.replace_all
Expr.str.replace_many
Expr.str.reverse
- Expr.str.rjust
- Expr.str.rstrip
Expr.str.slice
Expr.str.split
Expr.str.split_exact
Expr.str.splitn
Expr.str.starts_with
- Expr.str.strip
Expr.str.strip_chars
Expr.str.strip_chars_start
Expr.str.strip_chars_end
diff --git a/py-polars/docs/source/reference/expressions/temporal.rst b/py-polars/docs/source/reference/expressions/temporal.rst
index f5720ea9bb0d5..a82303ba737b7 100644
--- a/py-polars/docs/source/reference/expressions/temporal.rst
+++ b/py-polars/docs/source/reference/expressions/temporal.rst
@@ -18,32 +18,25 @@ The following methods are available under the `expr.dt` attribute.
Expr.dt.date
Expr.dt.datetime
Expr.dt.day
- Expr.dt.days
Expr.dt.dst_offset
Expr.dt.epoch
Expr.dt.hour
- Expr.dt.hours
Expr.dt.is_leap_year
Expr.dt.iso_year
Expr.dt.microsecond
- Expr.dt.microseconds
Expr.dt.millennium
Expr.dt.millisecond
- Expr.dt.milliseconds
Expr.dt.minute
- Expr.dt.minutes
Expr.dt.month
Expr.dt.month_end
Expr.dt.month_start
Expr.dt.nanosecond
- Expr.dt.nanoseconds
Expr.dt.offset_by
Expr.dt.ordinal_day
Expr.dt.quarter
Expr.dt.replace_time_zone
Expr.dt.round
Expr.dt.second
- Expr.dt.seconds
Expr.dt.strftime
Expr.dt.time
Expr.dt.timestamp
diff --git a/py-polars/docs/source/reference/lazyframe/group_by.rst b/py-polars/docs/source/reference/lazyframe/group_by.rst
index 23f1c0e40eeea..7d47fde028643 100644
--- a/py-polars/docs/source/reference/lazyframe/group_by.rst
+++ b/py-polars/docs/source/reference/lazyframe/group_by.rst
@@ -11,7 +11,6 @@ This namespace comes available by calling `LazyFrame.group_by(..)`.
LazyGroupBy.agg
LazyGroupBy.all
- LazyGroupBy.apply
LazyGroupBy.count
LazyGroupBy.first
LazyGroupBy.head
diff --git a/py-polars/docs/source/reference/lazyframe/miscellaneous.rst b/py-polars/docs/source/reference/lazyframe/miscellaneous.rst
index 0d06faf25eba4..cb2c832ea232b 100644
--- a/py-polars/docs/source/reference/lazyframe/miscellaneous.rst
+++ b/py-polars/docs/source/reference/lazyframe/miscellaneous.rst
@@ -11,7 +11,6 @@ Miscellaneous
LazyFrame.collect_async
LazyFrame.fetch
LazyFrame.lazy
- LazyFrame.map
LazyFrame.map_batches
LazyFrame.pipe
LazyFrame.profile
diff --git a/py-polars/docs/source/reference/lazyframe/modify_select.rst b/py-polars/docs/source/reference/lazyframe/modify_select.rst
index e2c3f065ad824..41c83b2c7a20c 100644
--- a/py-polars/docs/source/reference/lazyframe/modify_select.rst
+++ b/py-polars/docs/source/reference/lazyframe/modify_select.rst
@@ -21,10 +21,6 @@ Manipulation/selection
LazyFrame.gather_every
LazyFrame.group_by
LazyFrame.group_by_dynamic
- LazyFrame.group_by_rolling
- LazyFrame.groupby
- LazyFrame.groupby_dynamic
- LazyFrame.groupby_rolling
LazyFrame.head
LazyFrame.inspect
LazyFrame.interpolate
@@ -41,12 +37,10 @@ Manipulation/selection
LazyFrame.select_seq
LazyFrame.set_sorted
LazyFrame.shift
- LazyFrame.shift_and_fill
LazyFrame.slice
LazyFrame.sort
LazyFrame.sql
LazyFrame.tail
- LazyFrame.take_every
LazyFrame.top_k
LazyFrame.unique
LazyFrame.unnest
diff --git a/py-polars/docs/source/reference/series/categories.rst b/py-polars/docs/source/reference/series/categories.rst
index fd57271b46b97..90275af7e9ca6 100644
--- a/py-polars/docs/source/reference/series/categories.rst
+++ b/py-polars/docs/source/reference/series/categories.rst
@@ -11,6 +11,5 @@ The following methods are available under the `Series.cat` attribute.
Series.cat.get_categories
Series.cat.is_local
- Series.cat.set_ordering
Series.cat.to_local
Series.cat.uses_lexical_ordering
diff --git a/py-polars/docs/source/reference/series/computation.rst b/py-polars/docs/source/reference/series/computation.rst
index 68f3ca57e6409..9710a23dc7821 100644
--- a/py-polars/docs/source/reference/series/computation.rst
+++ b/py-polars/docs/source/reference/series/computation.rst
@@ -24,10 +24,6 @@ Computation
Series.cum_min
Series.cum_prod
Series.cum_sum
- Series.cummax
- Series.cummin
- Series.cumprod
- Series.cumsum
Series.cumulative_eval
Series.diff
Series.dot
@@ -44,13 +40,11 @@ Computation
Series.log
Series.log10
Series.log1p
- Series.map_dict
Series.pct_change
Series.peak_max
Series.peak_min
Series.rank
Series.replace
- Series.rolling_apply
Series.rolling_map
Series.rolling_max
Series.rolling_mean
diff --git a/py-polars/docs/source/reference/series/descriptive.rst b/py-polars/docs/source/reference/series/descriptive.rst
index dd4284493d1a2..4f7eb6ec011f9 100644
--- a/py-polars/docs/source/reference/series/descriptive.rst
+++ b/py-polars/docs/source/reference/series/descriptive.rst
@@ -11,27 +11,19 @@ Descriptive
Series.estimated_size
Series.has_nulls
Series.has_validity
- Series.is_boolean
Series.is_duplicated
Series.is_empty
Series.is_finite
- Series.is_first
Series.is_first_distinct
- Series.is_float
Series.is_in
Series.is_infinite
- Series.is_integer
- Series.is_last
Series.is_last_distinct
Series.is_nan
Series.is_not_nan
Series.is_not_null
Series.is_null
- Series.is_numeric
Series.is_sorted
- Series.is_temporal
Series.is_unique
- Series.is_utf8
Series.len
Series.lower_bound
Series.n_chunks
diff --git a/py-polars/docs/source/reference/series/list.rst b/py-polars/docs/source/reference/series/list.rst
index 2398fe0ea24d7..a9a11001402b9 100644
--- a/py-polars/docs/source/reference/series/list.rst
+++ b/py-polars/docs/source/reference/series/list.rst
@@ -16,7 +16,6 @@ The following methods are available under the `Series.list` attribute.
Series.list.arg_min
Series.list.concat
Series.list.contains
- Series.list.count_match
Series.list.count_matches
Series.list.diff
Series.list.eval
@@ -28,7 +27,6 @@ The following methods are available under the `Series.list` attribute.
Series.list.join
Series.list.last
Series.list.len
- Series.list.lengths
Series.list.max
Series.list.mean
Series.list.median
@@ -45,10 +43,9 @@ The following methods are available under the `Series.list` attribute.
Series.list.std
Series.list.sum
Series.list.tail
- Series.list.take
Series.list.to_array
Series.list.to_struct
Series.list.unique
Series.list.n_unique
Series.list.var
- Series.list.gather_every
\ No newline at end of file
+ Series.list.gather_every
diff --git a/py-polars/docs/source/reference/series/miscellaneous.rst b/py-polars/docs/source/reference/series/miscellaneous.rst
index b310ee6f49927..7928cf87ad4e2 100644
--- a/py-polars/docs/source/reference/series/miscellaneous.rst
+++ b/py-polars/docs/source/reference/series/miscellaneous.rst
@@ -6,11 +6,9 @@ Miscellaneous
.. autosummary::
:toctree: api/
- Series.apply
Series.equals
Series.map_elements
Series.reinterpret
- Series.series_equal
Series.set_sorted
Series.to_physical
Series.get_chunks
diff --git a/py-polars/docs/source/reference/series/modify_select.rst b/py-polars/docs/source/reference/series/modify_select.rst
index 7cd1b864aadc9..d7ad900293491 100644
--- a/py-polars/docs/source/reference/series/modify_select.rst
+++ b/py-polars/docs/source/reference/series/modify_select.rst
@@ -14,8 +14,6 @@ Manipulation/selection
Series.ceil
Series.clear
Series.clip
- Series.clip_max
- Series.clip_min
Series.clone
Series.cut
Series.drop_nans
@@ -47,19 +45,14 @@ Manipulation/selection
Series.sample
Series.scatter
Series.set
- Series.set_at_idx
Series.shift
- Series.shift_and_fill
Series.shrink_dtype
Series.shrink_to_fit
Series.shuffle
Series.slice
Series.sort
Series.tail
- Series.take
- Series.take_every
Series.to_dummies
Series.top_k
Series.unique
- Series.view
Series.zip_with
diff --git a/py-polars/docs/source/reference/series/string.rst b/py-polars/docs/source/reference/series/string.rst
index 93bc038619bb1..9f3d2006bdfa7 100644
--- a/py-polars/docs/source/reference/series/string.rst
+++ b/py-polars/docs/source/reference/series/string.rst
@@ -12,7 +12,6 @@ The following methods are available under the `Series.str` attribute.
Series.str.concat
Series.str.contains
Series.str.contains_any
- Series.str.count_match
Series.str.count_matches
Series.str.decode
Series.str.encode
@@ -24,29 +23,20 @@ The following methods are available under the `Series.str` attribute.
Series.str.find
Series.str.head
Series.str.json_decode
- Series.str.json_extract
Series.str.json_path_match
Series.str.len_bytes
Series.str.len_chars
- Series.str.lengths
- Series.str.ljust
- Series.str.lstrip
- Series.str.n_chars
Series.str.pad_end
Series.str.pad_start
- Series.str.parse_int
Series.str.replace
Series.str.replace_all
Series.str.replace_many
Series.str.reverse
- Series.str.rjust
- Series.str.rstrip
Series.str.slice
Series.str.split
Series.str.split_exact
Series.str.splitn
Series.str.starts_with
- Series.str.strip
Series.str.strip_chars
Series.str.strip_chars_start
Series.str.strip_chars_end
diff --git a/py-polars/docs/source/reference/series/temporal.rst b/py-polars/docs/source/reference/series/temporal.rst
index c9864ebd5961e..78f62c2edbd73 100644
--- a/py-polars/docs/source/reference/series/temporal.rst
+++ b/py-polars/docs/source/reference/series/temporal.rst
@@ -18,36 +18,29 @@ The following methods are available under the `Series.dt` attribute.
Series.dt.date
Series.dt.datetime
Series.dt.day
- Series.dt.days
Series.dt.dst_offset
Series.dt.epoch
Series.dt.hour
- Series.dt.hours
Series.dt.is_leap_year
Series.dt.iso_year
Series.dt.max
Series.dt.mean
Series.dt.median
Series.dt.microsecond
- Series.dt.microseconds
Series.dt.millennium
Series.dt.millisecond
- Series.dt.milliseconds
Series.dt.min
Series.dt.minute
- Series.dt.minutes
Series.dt.month
Series.dt.month_end
Series.dt.month_start
Series.dt.nanosecond
- Series.dt.nanoseconds
Series.dt.offset_by
Series.dt.ordinal_day
Series.dt.quarter
Series.dt.replace_time_zone
Series.dt.round
Series.dt.second
- Series.dt.seconds
Series.dt.strftime
Series.dt.time
Series.dt.timestamp
diff --git a/py-polars/polars/__init__.py b/py-polars/polars/__init__.py
index d7c996c7dfe17..cb2314348d186 100644
--- a/py-polars/polars/__init__.py
+++ b/py-polars/polars/__init__.py
@@ -101,7 +101,6 @@
all_horizontal,
any,
any_horizontal,
- apply,
approx_n_unique,
arange,
arctan2,
@@ -124,10 +123,6 @@
cum_reduce,
cum_sum,
cum_sum_horizontal,
- cumfold,
- cumreduce,
- cumsum,
- cumsum_horizontal,
date,
date_range,
date_ranges,
@@ -150,7 +145,6 @@
last,
len,
lit,
- map,
map_batches,
map_groups,
max,
@@ -356,8 +350,6 @@
"any_horizontal",
"cum_sum",
"cum_sum_horizontal",
- "cumsum",
- "cumsum_horizontal",
"max",
"max_horizontal",
"mean_horizontal",
@@ -366,7 +358,6 @@
"sum",
"sum_horizontal",
# polars.functions.lazy
- "apply",
"approx_n_unique",
"arange",
"arctan2",
@@ -402,7 +393,6 @@
"int_ranges",
"last",
"lit",
- "map",
"map_batches",
"map_groups",
"mean",
diff --git a/py-polars/polars/_utils/deprecation.py b/py-polars/polars/_utils/deprecation.py
index 6f53205a4f504..5f4395b4b5c65 100644
--- a/py-polars/polars/_utils/deprecation.py
+++ b/py-polars/polars/_utils/deprecation.py
@@ -67,14 +67,10 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
def deprecate_renamed_function(
- new_name: str, *, version: str, moved: bool = False
+ new_name: str, *, version: str
) -> Callable[[Callable[P, T]], Callable[P, T]]:
"""Decorator to mark a function as deprecated due to being renamed (or moved)."""
- moved_or_renamed = "moved" if moved else "renamed"
- return deprecate_function(
- f"It has been {moved_or_renamed} to `{new_name}`.",
- version=version,
- )
+ return deprecate_function(f"It has been renamed to `{new_name}`.", version=version)
def deprecate_parameter_as_positional(
diff --git a/py-polars/polars/config.py b/py-polars/polars/config.py
index 87f3630fbd030..57e887d6ce0ef 100644
--- a/py-polars/polars/config.py
+++ b/py-polars/polars/config.py
@@ -6,9 +6,6 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, get_args
-from polars._utils.deprecation import (
- deprecate_nonkeyword_arguments,
-)
from polars._utils.various import normalize_filepath
from polars.dependencies import json
@@ -313,23 +310,19 @@ def save_to_file(cls, file: Path | str) -> None:
file.write_text(cls.save())
@classmethod
- @deprecate_nonkeyword_arguments(version="0.19.3")
def state(
- cls,
- if_set: bool = False, # noqa: FBT001
- env_only: bool = False, # noqa: FBT001
+ cls, *, if_set: bool = False, env_only: bool = False
) -> dict[str, str | None]:
"""
Show the current state of all Config variables as a dict.
Parameters
----------
- if_set : bool
+ if_set
By default this will show the state of all `Config` environment variables.
change this to `True` to restrict the returned dictionary to include only
those that have been set to a specific value.
-
- env_only : bool
+ env_only
Include only Config environment variables in the output; some options (such
as "set_fmt_float") are set directly, not via an environment variable.
diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py
index 1c50d060191a8..faf1d276a86cb 100644
--- a/py-polars/polars/dataframe/frame.py
+++ b/py-polars/polars/dataframe/frame.py
@@ -44,9 +44,7 @@
from polars._utils.convert import parse_as_duration_string
from polars._utils.deprecation import (
deprecate_function,
- deprecate_nonkeyword_arguments,
deprecate_parameter_as_positional,
- deprecate_renamed_function,
deprecate_renamed_parameter,
deprecate_saturating,
issue_deprecation_warning,
@@ -1295,21 +1293,18 @@ def to_arrow(self) -> pa.Table:
return pa.Table.from_batches(record_batches)
@overload
- def to_dict(self, as_series: Literal[True] = ...) -> dict[str, Series]: ...
+ def to_dict(self, *, as_series: Literal[True] = ...) -> dict[str, Series]: ...
@overload
- def to_dict(self, as_series: Literal[False]) -> dict[str, list[Any]]: ...
+ def to_dict(self, *, as_series: Literal[False]) -> dict[str, list[Any]]: ...
@overload
def to_dict(
- self,
- as_series: bool, # noqa: FBT001
+ self, *, as_series: bool
) -> dict[str, Series] | dict[str, list[Any]]: ...
- @deprecate_nonkeyword_arguments(version="0.19.13")
def to_dict(
- self,
- as_series: bool = True, # noqa: FBT001
+ self, *, as_series: bool = True
) -> dict[str, Series] | dict[str, list[Any]]:
"""
Convert DataFrame to a dictionary mapping column name to values.
@@ -1417,14 +1412,13 @@ def to_dicts(self) -> list[dict[str, Any]]:
"""
return self.rows(named=True)
- @deprecate_nonkeyword_arguments(version="0.19.3")
def to_numpy(
self,
- structured: bool = False, # noqa: FBT001
*,
order: IndexOrder = "fortran",
writable: bool = False,
allow_copy: bool = True,
+ structured: bool = False,
use_pyarrow: bool | None = None,
) -> np.ndarray[Any, Any]:
"""
@@ -1442,12 +1436,6 @@ def to_numpy(
Parameters
----------
- structured
- Return a `structured array`_ with a data type that corresponds to the
- DataFrame schema. If set to `False` (default), a 2D ndarray is
- returned instead.
-
- .. _structured array: https://numpy.org/doc/stable/user/basics.rec.html
order
The index order of the returned NumPy array, either C-like or
Fortran-like. In general, using the Fortran-like index order is faster.
@@ -1461,6 +1449,12 @@ def to_numpy(
allow_copy
Allow memory to be copied to perform the conversion. If set to `False`,
causes conversions that are not zero-copy to fail.
+ structured
+ Return a `structured array`_ with a data type that corresponds to the
+ DataFrame schema. If set to `False` (default), a 2D ndarray is
+ returned instead.
+
+ .. _structured array: https://numpy.org/doc/stable/user/basics.rec.html
use_pyarrow
Use `pyarrow.Array.to_numpy
@@ -2432,8 +2426,6 @@ def write_csv(
quote_style: CsvQuoteStyle | None = ...,
) -> None: ...
- @deprecate_renamed_parameter("quote", "quote_char", version="0.19.8")
- @deprecate_renamed_parameter("has_header", "include_header", version="0.19.13")
def write_csv(
self,
file: str | Path | IO[str] | IO[bytes] | None = None,
@@ -2620,7 +2612,6 @@ def write_avro(
self._df.write_avro(file, compression, name)
- @deprecate_renamed_parameter("has_header", "include_header", version="0.19.13")
def write_excel(
self,
workbook: Workbook | IO[bytes] | Path | str | None = None,
@@ -3436,7 +3427,6 @@ def write_parquet(
data_page_size,
)
- @deprecate_renamed_parameter("if_exists", "if_table_exists", version="0.20.0")
def write_database(
self,
table_name: str,
@@ -4973,46 +4963,6 @@ def equals(self, other: DataFrame, *, null_equal: bool = True) -> bool:
"""
return self._df.equals(other._df, null_equal=null_equal)
- @deprecate_function(
- "DataFrame.replace is deprecated and will be removed in a future version. "
- "Please use\n"
- " df = df.with_columns(new_column.alias(column_name))\n"
- "instead.",
- version="0.19.0",
- )
- def replace(self, column: str, new_column: Series) -> Self:
- """
- Replace a column by a new Series.
-
- .. deprecated:: 0.19.0
- Use :meth:`with_columns` instead, e.g.
- `df = df.with_columns(new_column.alias(column_name))`.
-
- Parameters
- ----------
- column
- Column to replace.
- new_column
- New column to insert.
-
- Examples
- --------
- >>> df = pl.DataFrame({"foo": [1, 2, 3], "bar": [4, 5, 6]})
- >>> s = pl.Series([10, 20, 30])
- >>> df.replace("foo", s) # works in-place! # doctest: +SKIP
- shape: (3, 2)
- ┌─────┬─────┐
- │ foo ┆ bar │
- │ --- ┆ --- │
- │ i64 ┆ i64 │
- ╞═════╪═════╡
- │ 10 ┆ 4 │
- │ 20 ┆ 5 │
- │ 30 ┆ 6 │
- └─────┴─────┘
- """
- return self._replace(column, new_column)
-
def slice(self, offset: int, length: int | None = None) -> Self:
"""
Get a slice of this DataFrame.
@@ -7563,20 +7513,11 @@ def explode(
"""
return self.lazy().explode(columns, *more_columns).collect(_eager=True)
- @deprecate_nonkeyword_arguments(
- allowed_args=["self"],
- message=(
- "The order of the parameters of `pivot` will change in the next breaking release."
- " The order will become `index, columns, values` with `values` as an optional parameter."
- " Use keyword arguments to silence this warning."
- ),
- version="0.20.8",
- )
def pivot(
self,
- values: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None,
index: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None,
columns: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None,
+ values: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None,
aggregate_function: PivotAgg | Expr | None = None,
*,
maintain_order: bool = True,
@@ -7686,7 +7627,7 @@ def pivot(
└──────┴──────────┴──────────┘
Note that `pivot` is only available in eager mode. If you know the unique
- column values in advance, you can use :meth:`polars.LazyFrame.groupby` to
+ column values in advance, you can use :meth:`polars.LazyFrame.group_by` to
get the same result as above in lazy mode:
>>> index = pl.col("col1")
@@ -8176,7 +8117,6 @@ def partition_by(
return partitions
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
def shift(self, n: int = 1, *, fill_value: IntoExpr | None = None) -> DataFrame:
"""
Shift values by the given number of indices.
@@ -10848,379 +10788,6 @@ def count(self) -> DataFrame:
"""
return self.lazy().count().collect(_eager=True)
- @deprecate_renamed_function("group_by", version="0.19.0")
- def groupby(
- self,
- by: IntoExpr | Iterable[IntoExpr],
- *more_by: IntoExpr,
- maintain_order: bool = False,
- ) -> GroupBy:
- """
- Start a group by operation.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`DataFrame.group_by`.
-
- Parameters
- ----------
- by
- Column(s) to group by. Accepts expression input. Strings are parsed as
- column names.
- *more_by
- Additional columns to group by, specified as positional arguments.
- maintain_order
- Ensure that the order of the groups is consistent with the input data.
- This is slower than a default group by.
- Settings this to `True` blocks the possibility
- to run on the streaming engine.
-
- .. note::
- Within each group, the order of rows is always preserved, regardless
- of this argument.
-
- Returns
- -------
- GroupBy
- Object which can be used to perform aggregations.
- """
- return self.group_by(by, *more_by, maintain_order=maintain_order)
-
- @deprecate_renamed_function("rolling", version="0.19.0")
- def groupby_rolling(
- self,
- index_column: IntoExpr,
- *,
- period: str | timedelta,
- offset: str | timedelta | None = None,
- closed: ClosedInterval = "right",
- by: IntoExpr | Iterable[IntoExpr] | None = None,
- check_sorted: bool | None = None,
- ) -> RollingGroupBy:
- """
- Create rolling groups based on a time, Int32, or Int64 column.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`DataFrame.rolling`.
-
- Parameters
- ----------
- index_column
- Column used to group based on the time window.
- Often of type Date/Datetime.
- This column must be sorted in ascending order (or, if `by` is specified,
- then it must be sorted in ascending order within each group).
-
- In case of a rolling group by on indices, dtype needs to be one of
- {Int32, Int64}. Note that Int32 gets temporarily cast to Int64, so if
- performance matters use an Int64 column.
- period
- length of the window - must be non-negative
- offset
- offset of the window. Default is -period
- closed : {'right', 'left', 'both', 'none'}
- Define which sides of the temporal interval are closed (inclusive).
- by
- Also group by this column/these columns
- check_sorted
- Check whether the `index` column is sorted (or, if `by` is given,
- check whether it's sorted within each group).
- When the `by` argument is given, polars can not check sortedness
- by the metadata and has to do a full scan on the index column to
- verify data is sorted. This is expensive. If you are sure the
- data within the groups is sorted, you can set this to `False`.
- Doing so incorrectly will lead to incorrect output
- """
- return self.rolling(
- index_column,
- period=period,
- offset=offset,
- closed=closed,
- group_by=by,
- check_sorted=check_sorted,
- )
-
- @deprecate_renamed_function("rolling", version="0.19.9")
- def group_by_rolling(
- self,
- index_column: IntoExpr,
- *,
- period: str | timedelta,
- offset: str | timedelta | None = None,
- closed: ClosedInterval = "right",
- by: IntoExpr | Iterable[IntoExpr] | None = None,
- check_sorted: bool | None = None,
- ) -> RollingGroupBy:
- """
- Create rolling groups based on a time, Int32, or Int64 column.
-
- .. deprecated:: 0.19.9
- This method has been renamed to :func:`DataFrame.rolling`.
-
- Parameters
- ----------
- index_column
- Column used to group based on the time window.
- Often of type Date/Datetime.
- This column must be sorted in ascending order (or, if `by` is specified,
- then it must be sorted in ascending order within each group).
-
- In case of a rolling group by on indices, dtype needs to be one of
- {Int32, Int64}. Note that Int32 gets temporarily cast to Int64, so if
- performance matters use an Int64 column.
- period
- length of the window - must be non-negative
- offset
- offset of the window. Default is -period
- closed : {'right', 'left', 'both', 'none'}
- Define which sides of the temporal interval are closed (inclusive).
- by
- Also group by this column/these columns
- check_sorted
- Check whether `index_column` is sorted (or, if `by` is given,
- check whether it's sorted within each group).
- When the `by` argument is given, polars can not check sortedness
- by the metadata and has to do a full scan on the index column to
- verify data is sorted. This is expensive. If you are sure the
- data within the groups is sorted, you can set this to `False`.
- Doing so incorrectly will lead to incorrect output
- """
- return self.rolling(
- index_column,
- period=period,
- offset=offset,
- closed=closed,
- group_by=by,
- check_sorted=check_sorted,
- )
-
- @deprecate_renamed_function("group_by_dynamic", version="0.19.0")
- def groupby_dynamic(
- self,
- index_column: IntoExpr,
- *,
- every: str | timedelta,
- period: str | timedelta | None = None,
- offset: str | timedelta | None = None,
- truncate: bool = True,
- include_boundaries: bool = False,
- closed: ClosedInterval = "left",
- by: IntoExpr | Iterable[IntoExpr] | None = None,
- start_by: StartBy = "window",
- check_sorted: bool | None = None,
- ) -> DynamicGroupBy:
- """
- Group based on a time value (or index value of type Int32, Int64).
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`DataFrame.group_by_dynamic`.
-
- Parameters
- ----------
- index_column
- Column used to group based on the time window.
- Often of type Date/Datetime.
- This column must be sorted in ascending order (or, if `by` is specified,
- then it must be sorted in ascending order within each group).
-
- In case of a dynamic group by on indices, dtype needs to be one of
- {Int32, Int64}. Note that Int32 gets temporarily cast to Int64, so if
- performance matters use an Int64 column.
- every
- interval of the window
- period
- length of the window, if None it will equal 'every'
- offset
- offset of the window, only takes effect if `start_by` is `'window'`.
- Defaults to zero.
- truncate
- truncate the time value to the window lower bound
- include_boundaries
- Add the lower and upper bound of the window to the "_lower_bound" and
- "_upper_bound" columns. This will impact performance because it's harder to
- parallelize
- closed : {'left', 'right', 'both', 'none'}
- Define which sides of the temporal interval are closed (inclusive).
- by
- Also group by this column/these columns
- start_by : {'window', 'datapoint', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'}
- The strategy to determine the start of the first window by.
-
- * 'window': Start by taking the earliest timestamp, truncating it with
- `every`, and then adding `offset`.
- Note that weekly windows start on Monday.
- * 'datapoint': Start from the first encountered data point.
- * a day of the week (only takes effect if `every` contains `'w'`):
-
- * 'monday': Start the window on the Monday before the first data point.
- * 'tuesday': Start the window on the Tuesday before the first data point.
- * ...
- * 'sunday': Start the window on the Sunday before the first data point.
-
- The resulting window is then shifted back until the earliest datapoint
- is in or in front of it.
- check_sorted
- Check whether `index_column` is sorted (or, if `by` is given,
- check whether it's sorted within each group).
- When the `by` argument is given, polars can not check sortedness
- by the metadata and has to do a full scan on the index column to
- verify data is sorted. This is expensive. If you are sure the
- data within the groups is sorted, you can set this to `False`.
- Doing so incorrectly will lead to incorrect output
-
- Returns
- -------
- DynamicGroupBy
- Object you can call `.agg` on to aggregate by groups, the result
- of which will be sorted by `index_column` (but note that if `by` columns are
- passed, it will only be sorted within each `by` group).
- """ # noqa: W505
- return self.group_by_dynamic(
- index_column,
- every=every,
- period=period,
- offset=offset,
- truncate=truncate,
- include_boundaries=include_boundaries,
- closed=closed,
- group_by=by,
- start_by=start_by,
- check_sorted=check_sorted,
- )
-
- @deprecate_renamed_function("map_rows", version="0.19.0")
- def apply(
- self,
- function: Callable[[tuple[Any, ...]], Any],
- return_dtype: PolarsDataType | None = None,
- *,
- inference_size: int = 256,
- ) -> DataFrame:
- """
- Apply a custom/user-defined function (UDF) over the rows of the DataFrame.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`DataFrame.map_rows`.
-
- Parameters
- ----------
- function
- Custom function or lambda.
- return_dtype
- Output type of the operation. If none given, Polars tries to infer the type.
- inference_size
- Only used in the case when the custom function returns rows.
- This uses the first `n` rows to determine the output schema
- """
- return self.map_rows(function, return_dtype, inference_size=inference_size)
-
- @deprecate_function("Use `shift` instead.", version="0.19.12")
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
- def shift_and_fill(
- self,
- fill_value: int | str | float,
- *,
- n: int = 1,
- ) -> DataFrame:
- """
- Shift values by the given number of places and fill the resulting null values.
-
- .. deprecated:: 0.19.12
- Use :func:`shift` instead.
-
- Parameters
- ----------
- fill_value
- fill None values with this value.
- n
- Number of places to shift (may be negative).
- """
- return self.shift(n, fill_value=fill_value)
-
- @deprecate_renamed_function("gather_every", version="0.19.12")
- def take_every(self, n: int, offset: int = 0) -> DataFrame:
- """
- Take every nth row in the DataFrame and return as a new DataFrame.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :func:`gather_every`.
-
- Parameters
- ----------
- n
- Gather every *n*-th row.
- offset
- Starting index.
- """
- return self.gather_every(n, offset)
-
- @deprecate_renamed_function("get_column_index", version="0.19.14")
- def find_idx_by_name(self, name: str) -> int:
- """
- Find the index of a column by name.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :func:`get_column_index`.
-
- Parameters
- ----------
- name
- Name of the column to find.
- """
- return self.get_column_index(name)
-
- @deprecate_renamed_function("insert_column", version="0.19.14")
- @deprecate_renamed_parameter("series", "column", version="0.19.14")
- def insert_at_idx(self, index: int, column: Series) -> Self:
- """
- Insert a Series at a certain column index. This operation is in place.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :func:`insert_column`.
-
- Parameters
- ----------
- index
- Column to insert the new `Series` column.
- column
- `Series` to insert.
- """
- return self.insert_column(index, column)
-
- @deprecate_renamed_function("replace_column", version="0.19.14")
- @deprecate_renamed_parameter("series", "new_column", version="0.19.14")
- def replace_at_idx(self, index: int, new_column: Series) -> Self:
- """
- Replace a column at an index location.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :func:`replace_column`.
-
- Parameters
- ----------
- index
- Column index.
- new_column
- Series that will replace the column.
- """
- return self.replace_column(index, new_column)
-
- @deprecate_renamed_function("equals", version="0.19.16")
- def frame_equal(self, other: DataFrame, *, null_equal: bool = True) -> bool:
- """
- Check whether the DataFrame is equal to another DataFrame.
-
- .. deprecated:: 0.19.16
- This method has been renamed to :func:`equals`.
-
- Parameters
- ----------
- other
- DataFrame to compare with.
- null_equal
- Consider null values as equal.
- """
- return self.equals(other, null_equal=null_equal)
-
def _prepare_other_arg(other: Any, length: int | None = None) -> Series:
# if not a series create singleton series such that it will broadcast
diff --git a/py-polars/polars/dataframe/group_by.py b/py-polars/polars/dataframe/group_by.py
index ad67f68d5b155..fafa24456e271 100644
--- a/py-polars/polars/dataframe/group_by.py
+++ b/py-polars/polars/dataframe/group_by.py
@@ -773,21 +773,6 @@ def sum(self) -> DataFrame:
"""
return self.agg(F.all().sum())
- @deprecate_renamed_function("map_groups", version="0.19.0")
- def apply(self, function: Callable[[DataFrame], DataFrame]) -> DataFrame:
- """
- Apply a custom/user-defined function (UDF) over the groups as a sub-DataFrame.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`GroupBy.map_groups`.
-
- Parameters
- ----------
- function
- Custom function.
- """
- return self.map_groups(function)
-
class RollingGroupBy:
"""
@@ -938,29 +923,6 @@ def map_groups(
.collect(no_optimization=True)
)
- @deprecate_renamed_function("map_groups", version="0.19.0")
- def apply(
- self,
- function: Callable[[DataFrame], DataFrame],
- schema: SchemaDict | None,
- ) -> DataFrame:
- """
- Apply a custom/user-defined function (UDF) over the groups as a new DataFrame.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`RollingGroupBy.map_groups`.
-
- Parameters
- ----------
- function
- Function to apply over each group of the `LazyFrame`.
- schema
- Schema of the output function. This has to be known statically. If the
- given schema is incorrect, this is a bug in the caller's query and may
- lead to errors. If set to None, polars assumes the schema is unchanged.
- """
- return self.map_groups(function, schema)
-
class DynamicGroupBy:
"""
@@ -1135,26 +1097,3 @@ def map_groups(
.map_groups(function, schema)
.collect(no_optimization=True)
)
-
- @deprecate_renamed_function("map_groups", version="0.19.0")
- def apply(
- self,
- function: Callable[[DataFrame], DataFrame],
- schema: SchemaDict | None,
- ) -> DataFrame:
- """
- Apply a custom/user-defined function (UDF) over the groups as a new DataFrame.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`DynamicGroupBy.map_groups`.
-
- Parameters
- ----------
- function
- Function to apply over each group of the `LazyFrame`.
- schema
- Schema of the output function. This has to be known statically. If the
- given schema is incorrect, this is a bug in the caller's query and may
- lead to errors. If set to None, polars assumes the schema is unchanged.
- """
- return self.map_groups(function, schema)
diff --git a/py-polars/polars/datatypes/__init__.py b/py-polars/polars/datatypes/__init__.py
index 2c9ed7bc02518..ea3e93bfd4683 100644
--- a/py-polars/polars/datatypes/__init__.py
+++ b/py-polars/polars/datatypes/__init__.py
@@ -53,7 +53,6 @@
py_type_to_constructor,
)
from polars.datatypes.convert import (
- dtype_to_ctype,
dtype_to_ffiname,
dtype_to_py_type,
is_polars_dtype,
@@ -126,7 +125,6 @@
"polars_type_to_constructor",
"py_type_to_constructor",
# convert
- "dtype_to_ctype",
"dtype_to_ffiname",
"dtype_to_py_type",
"is_polars_dtype",
diff --git a/py-polars/polars/datatypes/classes.py b/py-polars/polars/datatypes/classes.py
index e3cb4e88a25d7..b186d7348cf9d 100644
--- a/py-polars/polars/datatypes/classes.py
+++ b/py-polars/polars/datatypes/classes.py
@@ -51,10 +51,6 @@ def base_type(cls) -> DataTypeClass: # noqa: D102
def is_(cls, other: PolarsDataType) -> bool: # noqa: D102
...
- @classmethod
- def is_not(cls, other: PolarsDataType) -> bool: # noqa: D102
- ...
-
@classmethod
def is_numeric(cls) -> bool: # noqa: D102
...
@@ -144,38 +140,6 @@ def is_(self, other: PolarsDataType) -> bool:
"""
return self == other and hash(self) == hash(other)
- @classinstmethod # type: ignore[arg-type]
- def is_not(self, other: PolarsDataType) -> bool:
- """
- Check if this DataType is NOT the same as another DataType.
-
- .. deprecated:: 0.19.14
- Use `not dtype.is_(...)` instead.
-
- This is a stricter check than `self != other`, as it enforces an exact
- match of all dtype attributes for nested and/or uninitialised dtypes.
-
- Parameters
- ----------
- other
- the other polars dtype to compare with.
-
- Examples
- --------
- >>> pl.List != pl.List(pl.Int32)
- False
- >>> pl.List.is_not(pl.List(pl.Int32)) # doctest: +SKIP
- True
- """
- from polars._utils.deprecation import issue_deprecation_warning
-
- issue_deprecation_warning(
- "`DataType.is_not` is deprecated and will be removed in the next breaking release."
- " Use `not dtype.is_(...)` instead.",
- version="0.19.14",
- )
- return not self.is_(other)
-
@classmethod
def is_numeric(cls) -> bool:
"""Check whether the data type is a numeric type."""
diff --git a/py-polars/polars/datatypes/convert.py b/py-polars/polars/datatypes/convert.py
index cdfc76875858e..8604cc2365c4f 100644
--- a/py-polars/polars/datatypes/convert.py
+++ b/py-polars/polars/datatypes/convert.py
@@ -1,7 +1,6 @@
from __future__ import annotations
import contextlib
-import ctypes
import functools
import re
import sys
@@ -241,26 +240,6 @@ def DTYPE_TO_FFINAME(self) -> dict[PolarsDataType, str]:
Binary: "binary",
}
- @property
- @functools.lru_cache # noqa: B019
- def DTYPE_TO_CTYPE(self) -> dict[PolarsDataType, Any]:
- return {
- UInt8: ctypes.c_uint8,
- UInt16: ctypes.c_uint16,
- UInt32: ctypes.c_uint32,
- UInt64: ctypes.c_uint64,
- Int8: ctypes.c_int8,
- Int16: ctypes.c_int16,
- Int32: ctypes.c_int32,
- Int64: ctypes.c_int64,
- Float32: ctypes.c_float,
- Float64: ctypes.c_double,
- Datetime: ctypes.c_int64,
- Duration: ctypes.c_int64,
- Date: ctypes.c_int32,
- Time: ctypes.c_int64,
- }
-
@property
@functools.lru_cache # noqa: B019
def DTYPE_TO_PY_TYPE(self) -> dict[PolarsDataType, PythonDataType]:
@@ -343,16 +322,6 @@ def _dtype_str_repr_safe(o: Any) -> PolarsDataType | None:
DataTypeMappings = _DataTypeMappings()
-def dtype_to_ctype(dtype: PolarsDataType) -> Any:
- """Convert a Polars dtype to a ctype."""
- try:
- dtype = dtype.base_type()
- return DataTypeMappings.DTYPE_TO_CTYPE[dtype]
- except KeyError: # pragma: no cover
- msg = f"conversion of polars data type {dtype!r} to C-type not implemented"
- raise NotImplementedError(msg) from None
-
-
def dtype_to_ffiname(dtype: PolarsDataType) -> str:
"""Return FFI function name associated with the given Polars dtype."""
try:
diff --git a/py-polars/polars/expr/categorical.py b/py-polars/polars/expr/categorical.py
index ca00114c4e364..2d6ce76464434 100644
--- a/py-polars/polars/expr/categorical.py
+++ b/py-polars/polars/expr/categorical.py
@@ -2,12 +2,10 @@
from typing import TYPE_CHECKING
-from polars._utils.deprecation import deprecate_function
from polars._utils.wrap import wrap_expr
if TYPE_CHECKING:
from polars import Expr
- from polars.type_aliases import CategoricalOrdering
class ExprCatNameSpace:
@@ -18,27 +16,6 @@ class ExprCatNameSpace:
def __init__(self, expr: Expr):
self._pyexpr = expr._pyexpr
- @deprecate_function(
- "Set the ordering directly on the datatype `pl.Categorical('lexical')`"
- " or `pl.Categorical('physical')` or `cast()` to the intended data type."
- " This method will be removed in the next breaking change",
- version="0.19.19",
- )
- def set_ordering(self, ordering: CategoricalOrdering) -> Expr:
- """
- Determine how this categorical series should be sorted.
-
- Parameters
- ----------
- ordering : {'physical', 'lexical'}
- Ordering type:
-
- - 'physical' -> Use the physical representation of the categories to
- determine the order (default).
- - 'lexical' -> Use the string values to determine the ordering.
- """
- return wrap_expr(self._pyexpr.cat_set_ordering(ordering))
-
def get_categories(self) -> Expr:
"""
Get the categories stored in this data type.
diff --git a/py-polars/polars/expr/datetime.py b/py-polars/polars/expr/datetime.py
index 1f622c70cf872..d765a1d30159e 100644
--- a/py-polars/polars/expr/datetime.py
+++ b/py-polars/polars/expr/datetime.py
@@ -9,7 +9,6 @@
from polars._utils.convert import parse_as_duration_string
from polars._utils.deprecation import (
deprecate_function,
- deprecate_renamed_function,
deprecate_saturating,
issue_deprecation_warning,
rename_use_earliest_to_ambiguous,
@@ -2349,73 +2348,3 @@ def dst_offset(self) -> Expr:
└─────────────────────────────┴──────────────┘
"""
return wrap_expr(self._pyexpr.dt_dst_offset())
-
- @deprecate_renamed_function("total_days", version="0.19.13")
- def days(self) -> Expr:
- """
- Extract the total days from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_days` instead.
- """
- return self.total_days()
-
- @deprecate_renamed_function("total_hours", version="0.19.13")
- def hours(self) -> Expr:
- """
- Extract the total hours from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_hours` instead.
- """
- return self.total_hours()
-
- @deprecate_renamed_function("total_minutes", version="0.19.13")
- def minutes(self) -> Expr:
- """
- Extract the total minutes from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_minutes` instead.
- """
- return self.total_minutes()
-
- @deprecate_renamed_function("total_seconds", version="0.19.13")
- def seconds(self) -> Expr:
- """
- Extract the total seconds from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_seconds` instead.
- """
- return self.total_seconds()
-
- @deprecate_renamed_function("total_milliseconds", version="0.19.13")
- def milliseconds(self) -> Expr:
- """
- Extract the total milliseconds from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_milliseconds` instead.
- """
- return self.total_milliseconds()
-
- @deprecate_renamed_function("total_microseconds", version="0.19.13")
- def microseconds(self) -> Expr:
- """
- Extract the total microseconds from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_microseconds` instead.
- """
- return self.total_microseconds()
-
- @deprecate_renamed_function("total_nanoseconds", version="0.19.13")
- def nanoseconds(self) -> Expr:
- """
- Extract the total nanoseconds from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_nanoseconds` instead.
- """
- return self.total_nanoseconds()
diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py
index f5d18b2dd4843..cafba41eaa5b2 100644
--- a/py-polars/polars/expr/expr.py
+++ b/py-polars/polars/expr/expr.py
@@ -28,9 +28,6 @@
from polars._utils.convert import negate_duration_string, parse_as_duration_string
from polars._utils.deprecation import (
deprecate_function,
- deprecate_nonkeyword_arguments,
- deprecate_renamed_function,
- deprecate_renamed_parameter,
deprecate_saturating,
issue_deprecation_warning,
validate_rolling_aggs_arguments,
@@ -420,7 +417,6 @@ def to_physical(self) -> Self:
"""
return self._from_pyexpr(self._pyexpr.to_physical())
- @deprecate_renamed_parameter("drop_nulls", "ignore_nulls", version="0.19.0")
def any(self, *, ignore_nulls: bool = True) -> Self:
"""
Return whether any of the values in the column are `True`.
@@ -476,7 +472,6 @@ def any(self, *, ignore_nulls: bool = True) -> Self:
"""
return self._from_pyexpr(self._pyexpr.any(ignore_nulls))
- @deprecate_renamed_parameter("drop_nulls", "ignore_nulls", version="0.19.0")
def all(self, *, ignore_nulls: bool = True) -> Self:
"""
Return whether all values in the column are `True`.
@@ -710,196 +705,6 @@ def alias(self, name: str) -> Self:
"""
return self._from_pyexpr(self._pyexpr.alias(name))
- @deprecate_renamed_function("name.map", moved=True, version="0.19.12")
- def map_alias(self, function: Callable[[str], str]) -> Self:
- """
- Rename the output of an expression by mapping a function over the root name.
-
- .. deprecated:: 0.19.12
- This method has been renamed to :func:`name.map`.
-
- Parameters
- ----------
- function
- Function that maps a root name to a new name.
-
- See Also
- --------
- keep_name
- prefix
- suffix
-
- Examples
- --------
- Remove a common suffix and convert to lower case.
-
- >>> df = pl.DataFrame(
- ... {
- ... "A_reverse": [3, 2, 1],
- ... "B_reverse": ["z", "y", "x"],
- ... }
- ... )
- >>> df.with_columns(
- ... pl.all().reverse().name.map(lambda c: c.rstrip("_reverse").lower())
- ... )
- shape: (3, 4)
- ┌───────────┬───────────┬─────┬─────┐
- │ A_reverse ┆ B_reverse ┆ a ┆ b │
- │ --- ┆ --- ┆ --- ┆ --- │
- │ i64 ┆ str ┆ i64 ┆ str │
- ╞═══════════╪═══════════╪═════╪═════╡
- │ 3 ┆ z ┆ 1 ┆ x │
- │ 2 ┆ y ┆ 2 ┆ y │
- │ 1 ┆ x ┆ 3 ┆ z │
- └───────────┴───────────┴─────┴─────┘
- """
- return self.name.map(function) # type: ignore[return-value]
-
- @deprecate_renamed_function("name.prefix", moved=True, version="0.19.12")
- def prefix(self, prefix: str) -> Self:
- """
- Add a prefix to the root column name of the expression.
-
- .. deprecated:: 0.19.12
- This method has been renamed to :func:`name.prefix`.
-
- Parameters
- ----------
- prefix
- Prefix to add to the root column name.
-
- Notes
- -----
- This will undo any previous renaming operations on the expression.
-
- Due to implementation constraints, this method can only be called as the last
- expression in a chain.
-
- See Also
- --------
- suffix
-
- Examples
- --------
- >>> df = pl.DataFrame(
- ... {
- ... "a": [1, 2, 3],
- ... "b": ["x", "y", "z"],
- ... }
- ... )
- >>> df.with_columns(pl.all().reverse().name.prefix("reverse_"))
- shape: (3, 4)
- ┌─────┬─────┬───────────┬───────────┐
- │ a ┆ b ┆ reverse_a ┆ reverse_b │
- │ --- ┆ --- ┆ --- ┆ --- │
- │ i64 ┆ str ┆ i64 ┆ str │
- ╞═════╪═════╪═══════════╪═══════════╡
- │ 1 ┆ x ┆ 3 ┆ z │
- │ 2 ┆ y ┆ 2 ┆ y │
- │ 3 ┆ z ┆ 1 ┆ x │
- └─────┴─────┴───────────┴───────────┘
- """
- return self.name.prefix(prefix) # type: ignore[return-value]
-
- @deprecate_renamed_function("name.suffix", moved=True, version="0.19.12")
- def suffix(self, suffix: str) -> Self:
- """
- Add a suffix to the root column name of the expression.
-
- .. deprecated:: 0.19.12
- This method has been renamed to :func:`name.suffix`.
-
- Parameters
- ----------
- suffix
- Suffix to add to the root column name.
-
- Notes
- -----
- This will undo any previous renaming operations on the expression.
-
- Due to implementation constraints, this method can only be called as the last
- expression in a chain.
-
- See Also
- --------
- prefix
-
- Examples
- --------
- >>> df = pl.DataFrame(
- ... {
- ... "a": [1, 2, 3],
- ... "b": ["x", "y", "z"],
- ... }
- ... )
- >>> df.with_columns(pl.all().reverse().name.suffix("_reverse"))
- shape: (3, 4)
- ┌─────┬─────┬───────────┬───────────┐
- │ a ┆ b ┆ a_reverse ┆ b_reverse │
- │ --- ┆ --- ┆ --- ┆ --- │
- │ i64 ┆ str ┆ i64 ┆ str │
- ╞═════╪═════╪═══════════╪═══════════╡
- │ 1 ┆ x ┆ 3 ┆ z │
- │ 2 ┆ y ┆ 2 ┆ y │
- │ 3 ┆ z ┆ 1 ┆ x │
- └─────┴─────┴───────────┴───────────┘
- """
- return self.name.suffix(suffix) # type: ignore[return-value]
-
- @deprecate_renamed_function("name.keep", moved=True, version="0.19.12")
- def keep_name(self) -> Self:
- """
- Keep the original root name of the expression.
-
- .. deprecated:: 0.19.12
- This method has been renamed to :func:`name.keep`.
-
- Notes
- -----
- Due to implementation constraints, this method can only be called as the last
- expression in a chain.
-
- See Also
- --------
- alias
-
- Examples
- --------
- Undo an alias operation.
-
- >>> df = pl.DataFrame(
- ... {
- ... "a": [1, 2],
- ... "b": [3, 4],
- ... }
- ... )
- >>> df.with_columns((pl.col("a") * 9).alias("c").name.keep())
- shape: (2, 2)
- ┌─────┬─────┐
- │ a ┆ b │
- │ --- ┆ --- │
- │ i64 ┆ i64 │
- ╞═════╪═════╡
- │ 9 ┆ 3 │
- │ 18 ┆ 4 │
- └─────┴─────┘
-
- Prevent errors due to duplicate column names.
-
- >>> df.select((pl.lit(10) / pl.all()).name.keep())
- shape: (2, 2)
- ┌──────┬──────────┐
- │ a ┆ b │
- │ --- ┆ --- │
- │ f64 ┆ f64 │
- ╞══════╪══════════╡
- │ 10.0 ┆ 3.333333 │
- │ 5.0 ┆ 2.5 │
- └──────┴──────────┘
- """
- return self.name.keep() # type: ignore[return-value]
-
def exclude(
self,
columns: str | PolarsDataType | Collection[str] | Collection[PolarsDataType],
@@ -1063,16 +868,6 @@ def pipe(
'''
return function(self, *args, **kwargs)
- @deprecate_renamed_function("not_", version="0.19.2")
- def is_not(self) -> Self:
- """
- Negate a boolean expression.
-
- .. deprecated:: 0.19.2
- This method has been renamed to :func:`Expr.not_`.
- """
- return self.not_()
-
def not_(self) -> Self:
"""
Negate a boolean expression.
@@ -3011,7 +2806,6 @@ def get(self, index: int | Expr) -> Self:
index_lit = parse_as_expression(index)
return self._from_pyexpr(self._pyexpr.get(index_lit))
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
def shift(
self, n: int | IntoExprColumn = 1, *, fill_value: IntoExpr | None = None
) -> Self:
@@ -10738,14 +10532,13 @@ def sample(
self._pyexpr.sample_n(n, with_replacement, shuffle, seed)
)
- @deprecate_nonkeyword_arguments(version="0.19.10")
def ewm_mean(
self,
+ *,
com: float | None = None,
span: float | None = None,
half_life: float | None = None,
alpha: float | None = None,
- *,
adjust: bool = True,
min_periods: int = 1,
ignore_nulls: bool | None = None,
@@ -10940,14 +10733,13 @@ def ewm_mean_by(
)
return self._from_pyexpr(self._pyexpr.ewm_mean_by(by, half_life))
- @deprecate_nonkeyword_arguments(version="0.19.10")
def ewm_std(
self,
+ *,
com: float | None = None,
span: float | None = None,
half_life: float | None = None,
alpha: float | None = None,
- *,
adjust: bool = True,
bias: bool = False,
min_periods: int = 1,
@@ -11042,14 +10834,13 @@ def ewm_std(
self._pyexpr.ewm_std(alpha, adjust, bias, min_periods, ignore_nulls)
)
- @deprecate_nonkeyword_arguments(version="0.19.10")
def ewm_var(
self,
+ *,
com: float | None = None,
span: float | None = None,
half_life: float | None = None,
alpha: float | None = None,
- *,
adjust: bool = True,
bias: bool = False,
min_periods: int = 1,
@@ -11177,7 +10968,6 @@ def extend_constant(self, value: IntoExpr, n: int | IntoExprColumn) -> Self:
n = parse_as_expression(n)
return self._from_pyexpr(self._pyexpr.extend_constant(value, n))
- @deprecate_renamed_parameter("multithreaded", "parallel", version="0.19.0")
def value_counts(
self, *, sort: bool = False, parallel: bool = False, name: str = "count"
) -> Self:
@@ -11738,205 +11528,6 @@ def replace(
return self._from_pyexpr(self._pyexpr.replace(old, new, default, return_dtype))
- @deprecate_renamed_function("map_batches", version="0.19.0")
- def map(
- self,
- function: Callable[[Series], Series | Any],
- return_dtype: PolarsDataType | None = None,
- *,
- agg_list: bool = False,
- ) -> Self:
- """
- Apply a custom python function to a Series or sequence of Series.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`Expr.map_batches`.
-
- Parameters
- ----------
- function
- Lambda/ function to apply.
- return_dtype
- Dtype of the output Series.
- agg_list
- Aggregate list
- """
- return self.map_batches(function, return_dtype, agg_list=agg_list)
-
- @deprecate_renamed_function("map_elements", version="0.19.0")
- def apply(
- self,
- function: Callable[[Any], Any],
- return_dtype: PolarsDataType | None = None,
- *,
- skip_nulls: bool = True,
- pass_name: bool = False,
- strategy: MapElementsStrategy = "thread_local",
- ) -> Self:
- """
- Apply a custom/user-defined function (UDF) in a GroupBy or Projection context.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`Expr.map_elements`.
-
- Parameters
- ----------
- function
- Lambda/ function to apply.
- return_dtype
- Dtype of the output Series.
- If not set, the dtype will be
- `polars.Unknown`.
- skip_nulls
- Don't apply the function over values
- that contain nulls. This is faster.
- pass_name
- Pass the Series name to the custom function
- This is more expensive.
- strategy : {'thread_local', 'threading'}
- This functionality is in `alpha` stage. This may be removed
- /changed without it being considered a breaking change.
-
- - 'thread_local': run the python function on a single thread.
- - 'threading': run the python function on separate threads. Use with
- care as this can slow performance. This might only speed up
- your code if the amount of work per element is significant
- and the python function releases the GIL (e.g. via calling
- a c function)
- """
- return self.map_elements(
- function,
- return_dtype=return_dtype,
- skip_nulls=skip_nulls,
- pass_name=pass_name,
- strategy=strategy,
- )
-
- @deprecate_renamed_function("rolling_map", version="0.19.0")
- def rolling_apply(
- self,
- function: Callable[[Series], Any],
- window_size: int,
- weights: list[float] | None = None,
- min_periods: int | None = None,
- *,
- center: bool = False,
- ) -> Self:
- """
- Apply a custom rolling window function.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`Expr.rolling_map`.
-
- Parameters
- ----------
- function
- Aggregation function
- window_size
- The length of the window.
- weights
- An optional slice with the same length as the window that will be multiplied
- elementwise with the values in the window.
- min_periods
- The number of values in the window that should be non-null before computing
- a result. If None, it will be set equal to:
-
- - the window size, if `window_size` is a fixed integer
- - 1, if `window_size` is a dynamic temporal size
- center
- Set the labels at the center of the window
- """
- return self.rolling_map(
- function, window_size, weights, min_periods, center=center
- )
-
- @deprecate_renamed_function("is_first_distinct", version="0.19.3")
- def is_first(self) -> Self:
- """
- Return a boolean mask indicating the first occurrence of each distinct value.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`Expr.is_first_distinct`.
-
- Returns
- -------
- Expr
- Expression of data type :class:`Boolean`.
- """
- return self.is_first_distinct()
-
- @deprecate_renamed_function("is_last_distinct", version="0.19.3")
- def is_last(self) -> Self:
- """
- Return a boolean mask indicating the last occurrence of each distinct value.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`Expr.is_last_distinct`.
-
- Returns
- -------
- Expr
- Expression of data type :class:`Boolean`.
- """
- return self.is_last_distinct()
-
- @deprecate_function("Use `clip` instead.", version="0.19.12")
- def clip_min(
- self, lower_bound: NumericLiteral | TemporalLiteral | IntoExprColumn
- ) -> Self:
- """
- Clip (limit) the values in an array to a `min` boundary.
-
- .. deprecated:: 0.19.12
- Use :func:`clip` instead.
-
- Parameters
- ----------
- lower_bound
- Lower bound.
- """
- return self.clip(lower_bound=lower_bound)
-
- @deprecate_function("Use `clip` instead.", version="0.19.12")
- def clip_max(
- self, upper_bound: NumericLiteral | TemporalLiteral | IntoExprColumn
- ) -> Self:
- """
- Clip (limit) the values in an array to a `max` boundary.
-
- .. deprecated:: 0.19.12
- Use :func:`clip` instead.
-
- Parameters
- ----------
- upper_bound
- Upper bound.
- """
- return self.clip(upper_bound=upper_bound)
-
- @deprecate_function("Use `shift` instead.", version="0.19.12")
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
- def shift_and_fill(
- self,
- fill_value: IntoExpr,
- *,
- n: int = 1,
- ) -> Self:
- """
- Shift values by the given number of places and fill the resulting null values.
-
- .. deprecated:: 0.19.12
- Use :func:`shift` instead.
-
- Parameters
- ----------
- fill_value
- Fill None values with the result of this expression.
- n
- Number of places to shift (may be negative).
- """
- return self.shift(n, fill_value=fill_value)
-
@deprecate_function(
"Use `polars.plugins.register_plugin_function` instead.", version="0.20.16"
)
@@ -12021,174 +11612,6 @@ def register_plugin(
pass_name_to_apply=pass_name_to_apply,
)
- @deprecate_renamed_function("register_plugin", version="0.19.12")
- def _register_plugin(
- self,
- *,
- lib: str,
- symbol: str,
- args: list[IntoExpr] | None = None,
- kwargs: dict[Any, Any] | None = None,
- is_elementwise: bool = False,
- input_wildcard_expansion: bool = False,
- auto_explode: bool = False,
- cast_to_supertypes: bool = False,
- ) -> Expr:
- return self.register_plugin(
- lib=lib,
- symbol=symbol,
- args=args,
- kwargs=kwargs,
- is_elementwise=is_elementwise,
- input_wildcard_expansion=input_wildcard_expansion,
- returns_scalar=auto_explode,
- cast_to_supertypes=cast_to_supertypes,
- )
-
- @deprecate_renamed_function("gather_every", version="0.19.14")
- def take_every(self, n: int, offset: int = 0) -> Self:
- """
- Take every nth value in the Series and return as a new Series.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`gather_every`.
-
- Parameters
- ----------
- n
- Gather every *n*-th row.
- offset
- Starting index.
- """
- return self.gather_every(n, offset)
-
- @deprecate_renamed_function("gather", version="0.19.14")
- def take(
- self, indices: int | list[int] | Expr | Series | np.ndarray[Any, Any]
- ) -> Self:
- """
- Take values by index.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`gather`.
-
- Parameters
- ----------
- indices
- An expression that leads to a UInt32 dtyped Series.
- """
- return self.gather(indices)
-
- @deprecate_renamed_function("cum_sum", version="0.19.14")
- def cumsum(self, *, reverse: bool = False) -> Self:
- """
- Get an array with the cumulative sum computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_sum`.
-
- Parameters
- ----------
- reverse
- Reverse the operation.
- """
- return self.cum_sum(reverse=reverse)
-
- @deprecate_renamed_function("cum_prod", version="0.19.14")
- def cumprod(self, *, reverse: bool = False) -> Self:
- """
- Get an array with the cumulative product computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_prod`.
-
- Parameters
- ----------
- reverse
- Reverse the operation.
- """
- return self.cum_prod(reverse=reverse)
-
- @deprecate_renamed_function("cum_min", version="0.19.14")
- def cummin(self, *, reverse: bool = False) -> Self:
- """
- Get an array with the cumulative min computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_min`.
-
- Parameters
- ----------
- reverse
- Reverse the operation.
- """
- return self.cum_min(reverse=reverse)
-
- @deprecate_renamed_function("cum_max", version="0.19.14")
- def cummax(self, *, reverse: bool = False) -> Self:
- """
- Get an array with the cumulative max computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_max`.
-
- Parameters
- ----------
- reverse
- Reverse the operation.
- """
- return self.cum_max(reverse=reverse)
-
- @deprecate_renamed_function("cum_count", version="0.19.14")
- def cumcount(self, *, reverse: bool = False) -> Self:
- """
- Get an array with the cumulative count computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_count`.
-
- Parameters
- ----------
- reverse
- Reverse the operation.
- """
- return self.cum_count(reverse=reverse)
-
- @deprecate_function(
- "It has been renamed to `replace`."
- " The default behavior has changed to keep any values not present in the mapping unchanged."
- " Pass `default=None` to keep existing behavior.",
- version="0.19.16",
- )
- @deprecate_renamed_parameter("remapping", "mapping", version="0.19.16")
- def map_dict(
- self,
- mapping: dict[Any, Any],
- *,
- default: Any = None,
- return_dtype: PolarsDataType | None = None,
- ) -> Self:
- """
- Replace values in column according to remapping dictionary.
-
- .. deprecated:: 0.19.16
- This method has been renamed to :meth:`replace`. The default behavior
- has changed to keep any values not present in the mapping unchanged.
- Pass `default=None` to keep existing behavior.
-
- Parameters
- ----------
- mapping
- Dictionary containing the before/after values to map.
- default
- Value to use when the remapping dict does not contain the lookup value.
- Accepts expression input. Non-expression inputs are parsed as literals.
- Use `pl.first()`, to keep the original value.
- return_dtype
- Set return dtype to override automatic return dtype determination.
- """
- return self.replace(mapping, default=default, return_dtype=return_dtype)
-
@classmethod
def from_json(cls, value: str) -> Self:
"""
diff --git a/py-polars/polars/expr/list.py b/py-polars/polars/expr/list.py
index 3c827794ffdb2..4eb37ead66fd2 100644
--- a/py-polars/polars/expr/list.py
+++ b/py-polars/polars/expr/list.py
@@ -5,10 +5,6 @@
import polars._reexport as pl
from polars import functions as F
-from polars._utils.deprecation import (
- deprecate_renamed_function,
- deprecate_renamed_parameter,
-)
from polars._utils.parse_expr_input import parse_as_expression
from polars._utils.wrap import wrap_expr
@@ -868,7 +864,6 @@ def diff(self, n: int = 1, null_behavior: NullBehavior = "ignore") -> Expr:
"""
return wrap_expr(self._pyexpr.list_diff(n, null_behavior))
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
def shift(self, n: int | IntoExprColumn = 1) -> Expr:
"""
Shift list values by the given number of indices.
@@ -1363,57 +1358,3 @@ def set_symmetric_difference(self, other: IntoExpr) -> Expr:
""" # noqa: W505.
other = parse_as_expression(other, str_as_lit=False)
return wrap_expr(self._pyexpr.list_set_operation(other, "symmetric_difference"))
-
- @deprecate_renamed_function("count_matches", version="0.19.3")
- def count_match(self, element: IntoExpr) -> Expr:
- """
- Count how often the value produced by `element` occurs.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`count_matches`.
-
- Parameters
- ----------
- element
- An expression that produces a single value
- """
- return self.count_matches(element)
-
- @deprecate_renamed_function("len", version="0.19.8")
- def lengths(self) -> Expr:
- """
- Return the number of elements in each list.
-
- .. deprecated:: 0.19.8
- This method has been renamed to :meth:`.len`.
- """
- return self.len()
-
- @deprecate_renamed_function("gather", version="0.19.14")
- @deprecate_renamed_parameter("index", "indices", version="0.19.14")
- def take(
- self,
- indices: Expr | Series | list[int] | list[list[int]],
- *,
- null_on_oob: bool = False,
- ) -> Expr:
- """
- Take sublists by multiple indices.
-
- The indices may be defined in a single column, or by sublists in another
- column of dtype `List`.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :func:`gather`.
-
- Parameters
- ----------
- indices
- Indices to return per sublist
- null_on_oob
- Behavior if an index is out of bounds:
- True -> set as null
- False -> raise an error
- Note that defaulting to raising an error is much cheaper
- """
- return self.gather(indices)
diff --git a/py-polars/polars/expr/meta.py b/py-polars/polars/expr/meta.py
index 77d005823c6ff..96a0e4eaee86f 100644
--- a/py-polars/polars/expr/meta.py
+++ b/py-polars/polars/expr/meta.py
@@ -4,10 +4,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, Literal, overload
-from polars._utils.deprecation import (
- deprecate_nonkeyword_arguments,
- deprecate_renamed_function,
-)
+from polars._utils.deprecation import deprecate_renamed_function
from polars._utils.various import normalize_filepath
from polars._utils.wrap import wrap_expr
from polars.exceptions import ComputeError
@@ -334,8 +331,7 @@ def tree_format(self, *, return_as_string: Literal[False]) -> None: ...
@overload
def tree_format(self, *, return_as_string: Literal[True]) -> str: ...
- @deprecate_nonkeyword_arguments(version="0.19.3")
- def tree_format(self, return_as_string: bool = False) -> str | None: # noqa: FBT001
+ def tree_format(self, *, return_as_string: bool = False) -> str | None:
"""
Format the expression as a tree.
diff --git a/py-polars/polars/expr/string.py b/py-polars/polars/expr/string.py
index 6a6dba9df45a7..27d4d84d54949 100644
--- a/py-polars/polars/expr/string.py
+++ b/py-polars/polars/expr/string.py
@@ -7,15 +7,13 @@
from polars import functions as F
from polars._utils.deprecation import (
deprecate_function,
- deprecate_renamed_function,
- deprecate_renamed_parameter,
issue_deprecation_warning,
rename_use_earliest_to_ambiguous,
)
from polars._utils.parse_expr_input import parse_as_expression
from polars._utils.various import find_stacklevel
from polars._utils.wrap import wrap_expr
-from polars.datatypes import Date, Datetime, Int32, Time, py_type_to_dtype
+from polars.datatypes import Date, Datetime, Time, py_type_to_dtype
from polars.datatypes.constants import N_INFER_DEFAULT
from polars.exceptions import ChronoFormatWarning
@@ -928,7 +926,6 @@ def pad_end(self, length: int, fill_char: str = " ") -> Expr:
"""
return wrap_expr(self._pyexpr.str_pad_end(length, fill_char))
- @deprecate_renamed_parameter("alignment", "length", version="0.19.12")
def zfill(self, length: int | IntoExprColumn) -> Expr:
"""
Pad the start of the string with zeros until it reaches the given length.
@@ -2450,181 +2447,6 @@ def to_integer(
base = parse_as_expression(base, str_as_lit=False)
return wrap_expr(self._pyexpr.str_to_integer(base, strict))
- @deprecate_renamed_function("to_integer", version="0.19.14")
- @deprecate_renamed_parameter("radix", "base", version="0.19.14")
- def parse_int(self, base: int | None = None, *, strict: bool = True) -> Expr:
- """
- Parse integers with base radix from strings.
-
- ParseError/Overflows become Nulls.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :func:`to_integer`.
-
- Parameters
- ----------
- base
- Positive integer which is the base of the string we are parsing.
- strict
- Bool, Default=True will raise any ParseError or overflow as ComputeError.
- False silently convert to Null.
- """
- if base is None:
- base = 2
- return self.to_integer(base=base, strict=strict).cast(Int32, strict=strict)
-
- @deprecate_renamed_function("strip_chars", version="0.19.3")
- def strip(self, characters: str | None = None) -> Expr:
- """
- Remove leading and trailing characters.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`strip_chars`.
-
- Parameters
- ----------
- characters
- The set of characters to be removed. All combinations of this set of
- characters will be stripped. If set to None (default), all whitespace is
- removed instead.
- """
- return self.strip_chars(characters)
-
- @deprecate_renamed_function("strip_chars_start", version="0.19.3")
- def lstrip(self, characters: str | None = None) -> Expr:
- """
- Remove leading characters.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`strip_chars_start`.
-
- Parameters
- ----------
- characters
- The set of characters to be removed. All combinations of this set of
- characters will be stripped. If set to None (default), all whitespace is
- removed instead.
- """
- return self.strip_chars_start(characters)
-
- @deprecate_renamed_function("strip_chars_end", version="0.19.3")
- def rstrip(self, characters: str | None = None) -> Expr:
- """
- Remove trailing characters.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`strip_chars_end`.
-
- Parameters
- ----------
- characters
- The set of characters to be removed. All combinations of this set of
- characters will be stripped. If set to None (default), all whitespace is
- removed instead.
- """
- return self.strip_chars_end(characters)
-
- @deprecate_renamed_function("count_matches", version="0.19.3")
- def count_match(self, pattern: str | Expr) -> Expr:
- """
- Count all successive non-overlapping regex matches.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`count_matches`.
-
- Parameters
- ----------
- pattern
- A valid regular expression pattern, compatible with the `regex crate
- `_.
-
- Returns
- -------
- Expr
- Expression of data type :class:`UInt32`. Returns null if the
- original value is null.
- """
- return self.count_matches(pattern)
-
- @deprecate_renamed_function("len_bytes", version="0.19.8")
- def lengths(self) -> Expr:
- """
- Return the length of each string as the number of bytes.
-
- .. deprecated:: 0.19.8
- This method has been renamed to :func:`len_bytes`.
- """
- return self.len_bytes()
-
- @deprecate_renamed_function("len_chars", version="0.19.8")
- def n_chars(self) -> Expr:
- """
- Return the length of each string as the number of characters.
-
- .. deprecated:: 0.19.8
- This method has been renamed to :func:`len_chars`.
- """
- return self.len_chars()
-
- @deprecate_renamed_function("pad_end", version="0.19.12")
- @deprecate_renamed_parameter("width", "length", version="0.19.12")
- def ljust(self, length: int, fill_char: str = " ") -> Expr:
- """
- Return the string left justified in a string of length `length`.
-
- .. deprecated:: 0.19.12
- This method has been renamed to :func:`pad_end`.
-
- Parameters
- ----------
- length
- Justify left to this length.
- fill_char
- Fill with this ASCII character.
- """
- return self.pad_end(length, fill_char)
-
- @deprecate_renamed_function("pad_start", version="0.19.12")
- @deprecate_renamed_parameter("width", "length", version="0.19.12")
- def rjust(self, length: int, fill_char: str = " ") -> Expr:
- """
- Return the string right justified in a string of length `length`.
-
- .. deprecated:: 0.19.12
- This method has been renamed to :func:`pad_start`.
-
- Parameters
- ----------
- length
- Justify right to this length.
- fill_char
- Fill with this ASCII character.
- """
- return self.pad_start(length, fill_char)
-
- @deprecate_renamed_function("json_decode", version="0.19.15")
- def json_extract(
- self,
- dtype: PolarsDataType | None = None,
- infer_schema_length: int | None = N_INFER_DEFAULT,
- ) -> Expr:
- """
- Parse string values as JSON.
-
- .. deprecated:: 0.19.15
- This method has been renamed to :meth:`json_decode`.
-
- Parameters
- ----------
- dtype
- The dtype to cast the extracted value to. If None, the dtype will be
- inferred from the JSON value.
- infer_schema_length
- The maximum number of rows to scan for schema inference.
- If set to `None`, the full data may be scanned *(this is slow)*.
- """
- return self.json_decode(dtype, infer_schema_length)
-
def contains_any(
self, patterns: IntoExpr, *, ascii_case_insensitive: bool = False
) -> Expr:
diff --git a/py-polars/polars/functions/__init__.py b/py-polars/polars/functions/__init__.py
index 70d7cbf80096f..fedd0ac2bff08 100644
--- a/py-polars/polars/functions/__init__.py
+++ b/py-polars/polars/functions/__init__.py
@@ -5,8 +5,6 @@
any_horizontal,
cum_sum,
cum_sum_horizontal,
- cumsum,
- cumsum_horizontal,
max,
max_horizontal,
mean_horizontal,
@@ -29,7 +27,6 @@
from polars.functions.col import col
from polars.functions.eager import align_frames, concat
from polars.functions.lazy import (
- apply,
approx_n_unique,
arctan2,
arctan2d,
@@ -44,8 +41,6 @@
cum_count,
cum_fold,
cum_reduce,
- cumfold,
- cumreduce,
element,
exclude,
field,
@@ -56,7 +51,6 @@
head,
implode,
last,
- map,
map_batches,
map_groups,
mean,
@@ -95,14 +89,12 @@
"all",
"any",
"cum_sum",
- "cumsum",
"max",
"min",
"sum",
"all_horizontal",
"any_horizontal",
"cum_sum_horizontal",
- "cumsum_horizontal",
"max_horizontal",
"min_horizontal",
"sum_horizontal",
@@ -122,7 +114,6 @@
"time_ranges",
"zeros",
# polars.functions.lazy
- "apply",
"arange",
"arctan2",
"arctan2d",
@@ -140,8 +131,6 @@
"cum_count",
"cum_fold",
"cum_reduce",
- "cumfold",
- "cumreduce",
"date", # named date_, see import above
"datetime", # named datetime_, see import above
"duration",
@@ -158,7 +147,6 @@
"int_ranges",
"last",
"lit",
- "map",
"map_batches",
"map_groups",
"mean",
diff --git a/py-polars/polars/functions/aggregation/__init__.py b/py-polars/polars/functions/aggregation/__init__.py
index 1d50e9770d834..245b458dfdc7c 100644
--- a/py-polars/polars/functions/aggregation/__init__.py
+++ b/py-polars/polars/functions/aggregation/__init__.py
@@ -2,7 +2,6 @@
all_horizontal,
any_horizontal,
cum_sum_horizontal,
- cumsum_horizontal,
max_horizontal,
mean_horizontal,
min_horizontal,
@@ -12,7 +11,6 @@
all,
any,
cum_sum,
- cumsum,
max,
min,
sum,
@@ -22,14 +20,12 @@
"all",
"any",
"cum_sum",
- "cumsum",
"max",
"min",
"sum",
"all_horizontal",
"any_horizontal",
"cum_sum_horizontal",
- "cumsum_horizontal",
"max_horizontal",
"mean_horizontal",
"min_horizontal",
diff --git a/py-polars/polars/functions/aggregation/horizontal.py b/py-polars/polars/functions/aggregation/horizontal.py
index 729a50d8de758..1ba6ac3105832 100644
--- a/py-polars/polars/functions/aggregation/horizontal.py
+++ b/py-polars/polars/functions/aggregation/horizontal.py
@@ -4,7 +4,6 @@
from typing import TYPE_CHECKING, Iterable
import polars.functions as F
-from polars._utils.deprecation import deprecate_renamed_function
from polars._utils.parse_expr_input import parse_as_list_of_expressions
from polars._utils.wrap import wrap_expr
from polars.datatypes import UInt32
@@ -285,20 +284,3 @@ def cum_sum_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr:
return F.cum_fold(F.lit(0).cast(UInt32), lambda a, b: a + b, exprs_wrapped).alias(
"cum_sum"
)
-
-
-@deprecate_renamed_function("cum_sum_horizontal", version="0.19.14")
-def cumsum_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr:
- """
- Cumulatively sum all values horizontally across columns.
-
- .. deprecated:: 0.19.14
- This function has been renamed to :func:`cum_sum_horizontal`.
-
- Parameters
- ----------
- *exprs
- Column(s) to use in the aggregation. Accepts expression input. Strings are
- parsed as column names, other non-expression inputs are parsed as literals.
- """
- return cum_sum_horizontal(*exprs).alias("cumsum")
diff --git a/py-polars/polars/functions/aggregation/vertical.py b/py-polars/polars/functions/aggregation/vertical.py
index ecae33eac1922..91945a020c4fc 100644
--- a/py-polars/polars/functions/aggregation/vertical.py
+++ b/py-polars/polars/functions/aggregation/vertical.py
@@ -3,7 +3,6 @@
from typing import TYPE_CHECKING
import polars.functions as F
-from polars._utils.deprecation import deprecate_renamed_function
if TYPE_CHECKING:
from polars import Expr
@@ -331,19 +330,3 @@ def cum_sum(*names: str) -> Expr:
└─────┘
"""
return F.col(*names).cum_sum()
-
-
-@deprecate_renamed_function("cum_sum", version="0.19.14")
-def cumsum(*names: str) -> Expr:
- """
- Cumulatively sum all values.
-
- .. deprecated:: 0.19.14
- This function has been renamed to :func:`cum_sum`.
-
- Parameters
- ----------
- *names
- Name(s) of the columns to use in the aggregation.
- """
- return cum_sum(*names)
diff --git a/py-polars/polars/functions/lazy.py b/py-polars/polars/functions/lazy.py
index 29f4eece17d54..d186d8745af84 100644
--- a/py-polars/polars/functions/lazy.py
+++ b/py-polars/polars/functions/lazy.py
@@ -8,7 +8,6 @@
from polars._utils.async_ import _AioDataFrameResult, _GeventDataFrameResult
from polars._utils.deprecation import (
deprecate_parameter_as_positional,
- deprecate_renamed_function,
issue_deprecation_warning,
)
from polars._utils.parse_expr_input import (
@@ -981,35 +980,6 @@ def map_batches(
)
-@deprecate_renamed_function("map_batches", version="0.19.0")
-def map(
- exprs: Sequence[str] | Sequence[Expr],
- function: Callable[[Sequence[Series]], Series],
- return_dtype: PolarsDataType | None = None,
-) -> Expr:
- """
- Map a custom function over multiple columns/expressions.
-
- .. deprecated:: 0.19.0
- This function has been renamed to :func:`map_batches`.
-
- Parameters
- ----------
- exprs
- Input Series to f
- function
- Function to apply over the input
- return_dtype
- dtype of the output Series
-
- Returns
- -------
- Expr
- Expression with the data type given by `return_dtype`.
- """
- return map_batches(exprs, function, return_dtype)
-
-
def map_groups(
exprs: Sequence[str | Expr],
function: Callable[[Sequence[Series]], Series | Any],
@@ -1098,39 +1068,6 @@ def map_groups(
)
-@deprecate_renamed_function("map_groups", version="0.19.0")
-def apply(
- exprs: Sequence[str | Expr],
- function: Callable[[Sequence[Series]], Series | Any],
- return_dtype: PolarsDataType | None = None,
- *,
- returns_scalar: bool = True,
-) -> Expr:
- """
- Apply a custom/user-defined function (UDF) in a GroupBy context.
-
- .. deprecated:: 0.19.0
- This function has been renamed to :func:`map_groups`.
-
- Parameters
- ----------
- exprs
- Input Series to f
- function
- Function to apply over the input
- return_dtype
- dtype of the output Series
- returns_scalar
- If the function returns a single scalar as output.
-
- Returns
- -------
- Expr
- Expression with the data type given by `return_dtype`.
- """
- return map_groups(exprs, function, return_dtype, returns_scalar=returns_scalar)
-
-
def fold(
acc: IntoExpr,
function: Callable[[Series, Series], Series],
@@ -2306,70 +2243,3 @@ def sql_expr(sql: str | Sequence[str]) -> Expr | list[Expr]:
return wrap_expr(plr.sql_expr(sql))
else:
return [wrap_expr(plr.sql_expr(q)) for q in sql]
-
-
-@deprecate_renamed_function("cum_fold", version="0.19.14")
-def cumfold(
- acc: IntoExpr,
- function: Callable[[Series, Series], Series],
- exprs: Sequence[Expr | str] | Expr,
- *,
- include_init: bool = False,
-) -> Expr:
- """
- Cumulatively accumulate over multiple columns horizontally/ row wise with a left fold.
-
- Every cumulative result is added as a separate field in a Struct column.
-
- .. deprecated:: 0.19.14
- This function has been renamed to :func:`cum_fold`.
-
- Parameters
- ----------
- acc
- Accumulator Expression. This is the value that will be initialized when the fold
- starts. For a sum this could for instance be lit(0).
- function
- Function to apply over the accumulator and the value.
- Fn(acc, value) -> new_value
- exprs
- Expressions to aggregate over. May also be a wildcard expression.
- include_init
- Include the initial accumulator state as struct field.
- """ # noqa: W505
- # in case of col("*")
- acc = parse_as_expression(acc, str_as_lit=True)
- if isinstance(exprs, pl.Expr):
- exprs = [exprs]
-
- exprs = parse_as_list_of_expressions(exprs)
- return wrap_expr(plr.cum_fold(acc, function, exprs, include_init))
-
-
-@deprecate_renamed_function("cum_reduce", version="0.19.14")
-def cumreduce(
- function: Callable[[Series, Series], Series],
- exprs: Sequence[Expr | str] | Expr,
-) -> Expr:
- """
- Cumulatively accumulate over multiple columns horizontally/ row wise with a left fold.
-
- Every cumulative result is added as a separate field in a Struct column.
-
- .. deprecated:: 0.19.14
- This function has been renamed to :func:`cum_reduce`.
-
- Parameters
- ----------
- function
- Function to apply over the accumulator and the value.
- Fn(acc, value) -> new_value
- exprs
- Expressions to aggregate over. May also be a wildcard expression.
- """ # noqa: W505
- # in case of col("*")
- if isinstance(exprs, pl.Expr):
- exprs = [exprs]
-
- exprs = parse_as_list_of_expressions(exprs)
- return wrap_expr(plr.cum_reduce(function, exprs))
diff --git a/py-polars/polars/io/csv/functions.py b/py-polars/polars/io/csv/functions.py
index 5693e089999b9..d4fd03f7fffd0 100644
--- a/py-polars/polars/io/csv/functions.py
+++ b/py-polars/polars/io/csv/functions.py
@@ -35,9 +35,6 @@
@deprecate_renamed_parameter("dtypes", "schema_overrides", version="0.20.31")
@deprecate_renamed_parameter("row_count_name", "row_index_name", version="0.20.4")
@deprecate_renamed_parameter("row_count_offset", "row_index_offset", version="0.20.4")
-@deprecate_renamed_parameter(
- old_name="comment_char", new_name="comment_prefix", version="0.19.14"
-)
def read_csv(
source: str | Path | IO[str] | IO[bytes] | bytes,
*,
@@ -603,9 +600,6 @@ def _read_csv_impl(
@deprecate_renamed_parameter("dtypes", "schema_overrides", version="0.20.31")
@deprecate_renamed_parameter("row_count_name", "row_index_name", version="0.20.4")
@deprecate_renamed_parameter("row_count_offset", "row_index_offset", version="0.20.4")
-@deprecate_renamed_parameter(
- old_name="comment_char", new_name="comment_prefix", version="0.19.14"
-)
def read_csv_batched(
source: str | Path,
*,
@@ -910,9 +904,6 @@ def read_csv_batched(
@deprecate_renamed_parameter("dtypes", "schema_overrides", version="0.20.31")
@deprecate_renamed_parameter("row_count_name", "row_index_name", version="0.20.4")
@deprecate_renamed_parameter("row_count_offset", "row_index_offset", version="0.20.4")
-@deprecate_renamed_parameter(
- old_name="comment_char", new_name="comment_prefix", version="0.19.14"
-)
def scan_csv(
source: str | Path | list[str] | list[Path],
*,
diff --git a/py-polars/polars/lazyframe/frame.py b/py-polars/polars/lazyframe/frame.py
index a7f34a7b67b3c..e79b07fba5846 100644
--- a/py-polars/polars/lazyframe/frame.py
+++ b/py-polars/polars/lazyframe/frame.py
@@ -29,7 +29,6 @@
from polars._utils.deprecation import (
deprecate_function,
deprecate_parameter_as_positional,
- deprecate_renamed_function,
deprecate_renamed_parameter,
deprecate_saturating,
issue_deprecation_warning,
@@ -2331,8 +2330,6 @@ def sink_ipc(
maintain_order=maintain_order,
)
- @deprecate_renamed_parameter("quote", "quote_char", version="0.19.8")
- @deprecate_renamed_parameter("has_header", "include_header", version="0.19.13")
@unstable()
def sink_csv(
self,
@@ -6377,343 +6374,3 @@ def count(self) -> Self:
└─────┴─────┴─────┘
"""
return self._from_pyldf(self._ldf.count())
-
- @deprecate_renamed_function("group_by", version="0.19.0")
- def groupby(
- self,
- by: IntoExpr | Iterable[IntoExpr],
- *more_by: IntoExpr,
- maintain_order: bool = False,
- ) -> LazyGroupBy:
- """
- Start a group by operation.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`LazyFrame.group_by`.
-
- Parameters
- ----------
- by
- Column(s) to group by. Accepts expression input. Strings are parsed as
- column names.
- *more_by
- Additional columns to group by, specified as positional arguments.
- maintain_order
- Ensure that the order of the groups is consistent with the input data.
- This is slower than a default group by.
- Settings this to `True` blocks the possibility
- to run on the streaming engine.
- """
- return self.group_by(by, *more_by, maintain_order=maintain_order)
-
- @deprecate_renamed_function("rolling", version="0.19.0")
- def groupby_rolling(
- self,
- index_column: IntoExpr,
- *,
- period: str | timedelta,
- offset: str | timedelta | None = None,
- closed: ClosedInterval = "right",
- by: IntoExpr | Iterable[IntoExpr] | None = None,
- check_sorted: bool | None = None,
- ) -> LazyGroupBy:
- """
- Create rolling groups based on a time, Int32, or Int64 column.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`LazyFrame.rolling`.
-
- Parameters
- ----------
- index_column
- Column used to group based on the time window.
- Often of type Date/Datetime.
- This column must be sorted in ascending order (or, if `by` is specified,
- then it must be sorted in ascending order within each group).
-
- In case of a rolling group by on indices, dtype needs to be one of
- {Int32, Int64}. Note that Int32 gets temporarily cast to Int64, so if
- performance matters use an Int64 column.
- period
- length of the window - must be non-negative
- offset
- offset of the window. Default is -period
- closed : {'right', 'left', 'both', 'none'}
- Define which sides of the temporal interval are closed (inclusive).
- by
- Also group by this column/these columns
- check_sorted
- Check whether `index_column` is sorted (or, if `by` is given,
- check whether it's sorted within each group).
- When the `by` argument is given, polars can not check sortedness
- by the metadata and has to do a full scan on the index column to
- verify data is sorted. This is expensive. If you are sure the
- data within the groups is sorted, you can set this to `False`.
- Doing so incorrectly will lead to incorrect output
-
- Returns
- -------
- LazyGroupBy
- Object you can call `.agg` on to aggregate by groups, the result
- of which will be sorted by `index_column` (but note that if `by` columns are
- passed, it will only be sorted within each `by` group).
- """
- return self.rolling(
- index_column,
- period=period,
- offset=offset,
- closed=closed,
- group_by=by,
- check_sorted=check_sorted,
- )
-
- @deprecate_renamed_function("rolling", version="0.19.9")
- def group_by_rolling(
- self,
- index_column: IntoExpr,
- *,
- period: str | timedelta,
- offset: str | timedelta | None = None,
- closed: ClosedInterval = "right",
- by: IntoExpr | Iterable[IntoExpr] | None = None,
- check_sorted: bool | None = None,
- ) -> LazyGroupBy:
- """
- Create rolling groups based on a time, Int32, or Int64 column.
-
- .. deprecated:: 0.19.9
- This method has been renamed to :func:`LazyFrame.rolling`.
-
- Parameters
- ----------
- index_column
- Column used to group based on the time window.
- Often of type Date/Datetime.
- This column must be sorted in ascending order (or, if `by` is specified,
- then it must be sorted in ascending order within each group).
-
- In case of a rolling group by on indices, dtype needs to be one of
- {Int32, Int64}. Note that Int32 gets temporarily cast to Int64, so if
- performance matters use an Int64 column.
- period
- length of the window - must be non-negative
- offset
- offset of the window. Default is -period
- closed : {'right', 'left', 'both', 'none'}
- Define which sides of the temporal interval are closed (inclusive).
- by
- Also group by this column/these columns
- check_sorted
- Check whether `index_column` is sorted (or, if `by` is given,
- check whether it's sorted within each group).
- When the `by` argument is given, polars can not check sortedness
- by the metadata and has to do a full scan on the index column to
- verify data is sorted. This is expensive. If you are sure the
- data within the groups is sorted, you can set this to `False`.
- Doing so incorrectly will lead to incorrect output
-
- Returns
- -------
- LazyGroupBy
- Object you can call `.agg` on to aggregate by groups, the result
- of which will be sorted by `index_column` (but note that if `by` columns are
- passed, it will only be sorted within each `by` group).
- """
- return self.rolling(
- index_column,
- period=period,
- offset=offset,
- closed=closed,
- group_by=by,
- check_sorted=check_sorted,
- )
-
- @deprecate_renamed_function("group_by_dynamic", version="0.19.0")
- def groupby_dynamic(
- self,
- index_column: IntoExpr,
- *,
- every: str | timedelta,
- period: str | timedelta | None = None,
- offset: str | timedelta | None = None,
- truncate: bool = True,
- include_boundaries: bool = False,
- closed: ClosedInterval = "left",
- by: IntoExpr | Iterable[IntoExpr] | None = None,
- start_by: StartBy = "window",
- check_sorted: bool | None = None,
- ) -> LazyGroupBy:
- """
- Group based on a time value (or index value of type Int32, Int64).
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`LazyFrame.group_by_dynamic`.
-
- Parameters
- ----------
- index_column
- Column used to group based on the time window.
- Often of type Date/Datetime.
- This column must be sorted in ascending order (or, if `by` is specified,
- then it must be sorted in ascending order within each group).
-
- In case of a dynamic group by on indices, dtype needs to be one of
- {Int32, Int64}. Note that Int32 gets temporarily cast to Int64, so if
- performance matters use an Int64 column.
- every
- interval of the window
- period
- length of the window, if None it will equal 'every'
- offset
- offset of the window, does not take effect if `start_by` is 'datapoint'.
- Defaults to zero.
- truncate
- truncate the time value to the window lower bound
- include_boundaries
- Add the lower and upper bound of the window to the "_lower_bound" and
- "_upper_bound" columns. This will impact performance because it's harder to
- parallelize
- closed : {'right', 'left', 'both', 'none'}
- Define which sides of the temporal interval are closed (inclusive).
- by
- Also group by this column/these columns
- start_by : {'window', 'datapoint', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'}
- The strategy to determine the start of the first window by.
-
- * 'window': Start by taking the earliest timestamp, truncating it with
- `every`, and then adding `offset`.
- Note that weekly windows start on Monday.
- * 'datapoint': Start from the first encountered data point.
- * a day of the week (only takes effect if `every` contains `'w'`):
-
- * 'monday': Start the window on the Monday before the first data point.
- * 'tuesday': Start the window on the Tuesday before the first data point.
- * ...
- * 'sunday': Start the window on the Sunday before the first data point.
-
- The resulting window is then shifted back until the earliest datapoint
- is in or in front of it.
- check_sorted
- Check whether `index_column` is sorted (or, if `by` is given,
- check whether it's sorted within each group).
- When the `by` argument is given, polars can not check sortedness
- by the metadata and has to do a full scan on the index column to
- verify data is sorted. This is expensive. If you are sure the
- data within the groups is sorted, you can set this to `False`.
- Doing so incorrectly will lead to incorrect output
-
- Returns
- -------
- LazyGroupBy
- Object you can call `.agg` on to aggregate by groups, the result
- of which will be sorted by `index_column` (but note that if `by` columns are
- passed, it will only be sorted within each `by` group).
- """ # noqa: W505
- return self.group_by_dynamic(
- index_column,
- every=every,
- period=period,
- offset=offset,
- truncate=truncate,
- include_boundaries=include_boundaries,
- closed=closed,
- group_by=by,
- start_by=start_by,
- check_sorted=check_sorted,
- )
-
- @deprecate_renamed_function("map_batches", version="0.19.0")
- def map(
- self,
- function: Callable[[DataFrame], DataFrame],
- *,
- predicate_pushdown: bool = True,
- projection_pushdown: bool = True,
- slice_pushdown: bool = True,
- no_optimizations: bool = False,
- schema: None | SchemaDict = None,
- validate_output_schema: bool = True,
- streamable: bool = False,
- ) -> Self:
- """
- Apply a custom function.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`LazyFrame.map_batches`.
-
- Parameters
- ----------
- function
- Lambda/ function to apply.
- predicate_pushdown
- Allow predicate pushdown optimization to pass this node.
- projection_pushdown
- Allow projection pushdown optimization to pass this node.
- slice_pushdown
- Allow slice pushdown optimization to pass this node.
- no_optimizations
- Turn off all optimizations past this point.
- schema
- Output schema of the function, if set to `None` we assume that the schema
- will remain unchanged by the applied function.
- validate_output_schema
- It is paramount that polars' schema is correct. This flag will ensure that
- the output schema of this function will be checked with the expected schema.
- Setting this to `False` will not do this check, but may lead to hard to
- debug bugs.
- streamable
- Whether the function that is given is eligible to be running with the
- streaming engine. That means that the function must produce the same result
- when it is executed in batches or when it is be executed on the full
- dataset.
- """
- return self.map_batches(
- function,
- predicate_pushdown=predicate_pushdown,
- projection_pushdown=projection_pushdown,
- slice_pushdown=slice_pushdown,
- no_optimizations=no_optimizations,
- schema=schema,
- validate_output_schema=validate_output_schema,
- streamable=streamable,
- )
-
- @deprecate_function("Use `shift` instead.", version="0.19.12")
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
- def shift_and_fill(
- self,
- fill_value: Expr | int | str | float,
- *,
- n: int = 1,
- ) -> Self:
- """
- Shift values by the given number of places and fill the resulting null values.
-
- .. deprecated:: 0.19.12
- Use :func:`shift` instead.
-
- Parameters
- ----------
- fill_value
- fill None values with the result of this expression.
- n
- Number of places to shift (may be negative).
- """
- return self.shift(n, fill_value=fill_value)
-
- @deprecate_renamed_function("gather_every", version="0.19.14")
- def take_every(self, n: int, offset: int = 0) -> Self:
- """
- Take every nth row in the LazyFrame and return as a new LazyFrame.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :meth:`gather_every`.
-
- Parameters
- ----------
- n
- Gather every *n*-th row.
- offset
- Starting index.
- """
- return self.gather_every(n, offset)
diff --git a/py-polars/polars/lazyframe/group_by.py b/py-polars/polars/lazyframe/group_by.py
index 6a750d84f2b20..e9c5f4437453e 100644
--- a/py-polars/polars/lazyframe/group_by.py
+++ b/py-polars/polars/lazyframe/group_by.py
@@ -657,26 +657,3 @@ def sum(self) -> LazyFrame:
└────────┴─────┴──────┴─────┘
"""
return self.agg(F.all().sum())
-
- @deprecate_renamed_function("map_groups", version="0.19.0")
- def apply(
- self,
- function: Callable[[DataFrame], DataFrame],
- schema: SchemaDict | None,
- ) -> LazyFrame:
- """
- Apply a custom/user-defined function (UDF) over the groups as a new DataFrame.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`LazyGroupBy.map_groups`.
-
- Parameters
- ----------
- function
- Function to apply over each group of the `LazyFrame`.
- schema
- Schema of the output function. This has to be known statically. If the
- given schema is incorrect, this is a bug in the caller's query and may
- lead to errors. If set to None, polars assumes the schema is unchanged.
- """
- return self.map_groups(function, schema)
diff --git a/py-polars/polars/selectors.py b/py-polars/polars/selectors.py
index d1ea2931f299e..976839dd23f2a 100644
--- a/py-polars/polars/selectors.py
+++ b/py-polars/polars/selectors.py
@@ -15,7 +15,6 @@
)
from polars import functions as F
-from polars._utils.deprecation import deprecate_nonkeyword_arguments
from polars._utils.parse_expr_input import _parse_inputs_as_iterable
from polars._utils.various import is_column, re_escape
from polars.datatypes import (
@@ -2426,8 +2425,7 @@ def starts_with(*prefix: str) -> SelectorType:
)
-@deprecate_nonkeyword_arguments(version="0.19.3")
-def string(include_categorical: bool = False) -> SelectorType: # noqa: FBT001
+def string(*, include_categorical: bool = False) -> SelectorType:
"""
Select all String (and, optionally, Categorical) string columns .
diff --git a/py-polars/polars/series/_numpy.py b/py-polars/polars/series/_numpy.py
deleted file mode 100644
index 6163172fc478e..0000000000000
--- a/py-polars/polars/series/_numpy.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from __future__ import annotations
-
-import ctypes
-from typing import Any
-
-import numpy as np
-
-
-# https://numpy.org/doc/stable/user/basics.subclassing.html#slightly-more-realistic-example-attribute-added-to-existing-array
-class SeriesView(np.ndarray): # type: ignore[type-arg]
- def __new__(
- cls, input_array: np.ndarray[Any, Any], owned_object: Any
- ) -> SeriesView:
- # Input array is an already formed ndarray instance
- # We first cast to be our class type
- obj = input_array.view(cls)
- # add the new attribute to the created instance
- obj.owned_series = owned_object
- # Finally, we must return the newly created object:
- return obj
-
- def __array_finalize__(self, obj: Any) -> None:
- # see InfoArray.__array_finalize__ for comments
- if obj is None:
- return
- self.owned_series = getattr(obj, "owned_series", None)
-
-
-# https://stackoverflow.com/questions/4355524/getting-data-from-ctypes-array-into-numpy
-def _ptr_to_numpy(
- ptr: int, shape: int | tuple[int, int] | tuple[int], ptr_type: Any
-) -> np.ndarray[Any, Any]:
- """
- Create a memory block view as a numpy array.
-
- Parameters
- ----------
- ptr
- C/Rust ptr casted to usize.
- shape
- Shape of the array values.
- ptr_type
- Example:
- f32: ctypes.c_float)
-
- Returns
- -------
- numpy.ndarray
- View of memory block as numpy array.
- """
- ptr_ctype = ctypes.cast(ptr, ctypes.POINTER(ptr_type))
- if isinstance(shape, int):
- shape = (shape,)
- return np.ctypeslib.as_array(ptr_ctype, shape)
diff --git a/py-polars/polars/series/categorical.py b/py-polars/polars/series/categorical.py
index 204a125853a97..82641bd41c836 100644
--- a/py-polars/polars/series/categorical.py
+++ b/py-polars/polars/series/categorical.py
@@ -2,7 +2,6 @@
from typing import TYPE_CHECKING
-from polars._utils.deprecation import deprecate_function
from polars._utils.unstable import unstable
from polars._utils.wrap import wrap_s
from polars.series.utils import expr_dispatch
@@ -10,7 +9,6 @@
if TYPE_CHECKING:
from polars import Series
from polars.polars import PySeries
- from polars.type_aliases import CategoricalOrdering
@expr_dispatch
@@ -22,31 +20,6 @@ class CatNameSpace:
def __init__(self, series: Series):
self._s: PySeries = series._s
- @deprecate_function(
- "Set the ordering directly on the datatype `pl.Categorical('lexical')`"
- " or `pl.Categorical('physical')` or `cast()` to the intended data type."
- " This method will be removed in the next breaking change",
- version="0.19.19",
- )
- def set_ordering(self, ordering: CategoricalOrdering) -> Series:
- """
- Determine how this categorical series should be sorted.
-
- .. deprecated:: 0.19.19
- Set the ordering directly on the datatype `pl.Categorical('lexical')`
- or `pl.Categorical('physical')` or `cast()` to the intended data type.
- This method will be removed in the next breaking change
-
- Parameters
- ----------
- ordering : {'physical', 'lexical'}
- Ordering type:
-
- - 'physical' -> Use the physical representation of the categories to
- determine the order (default).
- - 'lexical' -> Use the string values to determine the ordering.
- """
-
def get_categories(self) -> Series:
"""
Get the categories stored in this data type.
diff --git a/py-polars/polars/series/datetime.py b/py-polars/polars/series/datetime.py
index da75bdf47d65f..e3d57759dfd2b 100644
--- a/py-polars/polars/series/datetime.py
+++ b/py-polars/polars/series/datetime.py
@@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Iterable
from polars._utils.convert import to_py_date, to_py_datetime
-from polars._utils.deprecation import deprecate_function, deprecate_renamed_function
+from polars._utils.deprecation import deprecate_function
from polars._utils.unstable import unstable
from polars._utils.wrap import wrap_s
from polars.datatypes import Date, Datetime, Duration, Time
@@ -2093,73 +2093,3 @@ def dst_offset(self) -> Series:
0ms
]
"""
-
- @deprecate_renamed_function("total_days", version="0.19.13")
- def days(self) -> Series:
- """
- Extract the total days from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_days` instead.
- """
- return self.total_days()
-
- @deprecate_renamed_function("total_hours", version="0.19.13")
- def hours(self) -> Series:
- """
- Extract the total hours from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_hours` instead.
- """
- return self.total_hours()
-
- @deprecate_renamed_function("total_minutes", version="0.19.13")
- def minutes(self) -> Series:
- """
- Extract the total minutes from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_minutes` instead.
- """
- return self.total_minutes()
-
- @deprecate_renamed_function("total_seconds", version="0.19.13")
- def seconds(self) -> Series:
- """
- Extract the total seconds from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_seconds` instead.
- """
- return self.total_seconds()
-
- @deprecate_renamed_function("total_milliseconds", version="0.19.13")
- def milliseconds(self) -> Series:
- """
- Extract the total milliseconds from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_milliseconds` instead.
- """
- return self.total_milliseconds()
-
- @deprecate_renamed_function("total_microseconds", version="0.19.13")
- def microseconds(self) -> Series:
- """
- Extract the total microseconds from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_microseconds` instead.
- """
- return self.total_microseconds()
-
- @deprecate_renamed_function("total_nanoseconds", version="0.19.13")
- def nanoseconds(self) -> Series:
- """
- Extract the total nanoseconds from a Duration type.
-
- .. deprecated:: 0.19.13
- Use :meth:`total_nanoseconds` instead.
- """
- return self.total_nanoseconds()
diff --git a/py-polars/polars/series/list.py b/py-polars/polars/series/list.py
index 762d6d55eccbe..3c2ce4169e28b 100644
--- a/py-polars/polars/series/list.py
+++ b/py-polars/polars/series/list.py
@@ -3,10 +3,6 @@
from typing import TYPE_CHECKING, Any, Callable, Sequence
from polars import functions as F
-from polars._utils.deprecation import (
- deprecate_renamed_function,
- deprecate_renamed_parameter,
-)
from polars._utils.wrap import wrap_s
from polars.series.utils import expr_dispatch
@@ -672,7 +668,6 @@ def diff(self, n: int = 1, null_behavior: NullBehavior = "ignore") -> Series:
]
"""
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
def shift(self, n: int | IntoExprColumn = 1) -> Series:
"""
Shift list values by the given number of indices.
@@ -1057,53 +1052,3 @@ def set_symmetric_difference(self, other: Series) -> Series:
[5, 7, 8]
]
""" # noqa: W505
-
- @deprecate_renamed_function("count_matches", version="0.19.3")
- def count_match(
- self, element: float | str | bool | int | date | datetime | time | Expr
- ) -> Expr:
- """
- Count how often the value produced by `element` occurs.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`count_matches`.
-
- Parameters
- ----------
- element
- An expression that produces a single value
- """
-
- @deprecate_renamed_function("len", version="0.19.8")
- def lengths(self) -> Series:
- """
- Return the number of elements in each list.
-
- .. deprecated:: 0.19.8
- This method has been renamed to :meth:`.len`.
- """
-
- @deprecate_renamed_function("gather", version="0.19.14")
- @deprecate_renamed_parameter("index", "indices", version="0.19.14")
- def take(
- self,
- indices: Series | list[int] | list[list[int]],
- *,
- null_on_oob: bool = False,
- ) -> Series:
- """
- Take sublists by multiple indices.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :func:`gather`.
-
- Parameters
- ----------
- indices
- Indices to return per sublist
- null_on_oob
- Behavior if an index is out of bounds:
- True -> set as null
- False -> raise an error
- Note that defaulting to raising an error is much cheaper
- """
diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py
index 1072906db2472..f01212d65587e 100644
--- a/py-polars/polars/series/series.py
+++ b/py-polars/polars/series/series.py
@@ -41,8 +41,6 @@
)
from polars._utils.deprecation import (
deprecate_function,
- deprecate_nonkeyword_arguments,
- deprecate_renamed_function,
deprecate_renamed_parameter,
issue_deprecation_warning,
)
@@ -80,7 +78,6 @@
UInt32,
UInt64,
Unknown,
- dtype_to_ctype,
is_polars_dtype,
maybe_cast,
numpy_char_code_to_dtype,
@@ -124,7 +121,6 @@
from polars._utils.various import (
NoDefault,
)
- from polars.series._numpy import SeriesView
from polars.type_aliases import (
BufferInfo,
ClosedInterval,
@@ -137,7 +133,6 @@
NonNestedLiteral,
NullBehavior,
NumericLiteral,
- OneOrMoreDataTypes,
PolarsDataType,
PythonLiteral,
RankMethod,
@@ -1445,7 +1440,6 @@ def _repr_html_(self) -> str:
"""Format output data in HTML for display in Jupyter Notebooks."""
return self.to_frame()._repr_html_(_from_series=True)
- @deprecate_renamed_parameter("row", "index", version="0.19.3")
def item(self, index: int | None = None) -> Any:
"""
Return the Series as a scalar, or return the element at the given index.
@@ -1566,7 +1560,6 @@ def any(self, *, ignore_nulls: Literal[True] = ...) -> bool: ...
@overload
def any(self, *, ignore_nulls: bool) -> bool | None: ...
- @deprecate_renamed_parameter("drop_nulls", "ignore_nulls", version="0.19.0")
def any(self, *, ignore_nulls: bool = True) -> bool | None:
"""
Return whether any of the values in the column are `True`.
@@ -1609,7 +1602,6 @@ def all(self, *, ignore_nulls: Literal[True] = ...) -> bool: ...
@overload
def all(self, *, ignore_nulls: bool) -> bool | None: ...
- @deprecate_renamed_parameter("drop_nulls", "ignore_nulls", version="0.19.0")
def all(self, *, ignore_nulls: bool = True) -> bool | None:
"""
Return whether all values in the column are `True`.
@@ -2128,10 +2120,10 @@ def to_dummies(
def cut(
self,
breaks: Sequence[float],
+ *,
labels: Sequence[str] | None = ...,
break_point_label: str = ...,
category_label: str = ...,
- *,
left_closed: bool = ...,
include_breaks: bool = ...,
as_series: Literal[True] = ...,
@@ -2141,10 +2133,10 @@ def cut(
def cut(
self,
breaks: Sequence[float],
+ *,
labels: Sequence[str] | None = ...,
break_point_label: str = ...,
category_label: str = ...,
- *,
left_closed: bool = ...,
include_breaks: bool = ...,
as_series: Literal[False],
@@ -2154,25 +2146,23 @@ def cut(
def cut(
self,
breaks: Sequence[float],
+ *,
labels: Sequence[str] | None = ...,
break_point_label: str = ...,
category_label: str = ...,
- *,
left_closed: bool = ...,
include_breaks: bool = ...,
as_series: bool,
) -> Series | DataFrame: ...
- @deprecate_nonkeyword_arguments(["self", "breaks"], version="0.19.0")
- @deprecate_renamed_parameter("series", "as_series", version="0.19.0")
@unstable()
def cut(
self,
breaks: Sequence[float],
+ *,
labels: Sequence[str] | None = None,
break_point_label: str = "break_point",
category_label: str = "category",
- *,
left_closed: bool = False,
include_breaks: bool = False,
as_series: bool = True,
@@ -5527,7 +5517,6 @@ def map_elements(
self._s.apply_lambda(function, pl_return_dtype, skip_nulls)
)
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
def shift(self, n: int = 1, *, fill_value: IntoExpr | None = None) -> Series:
"""
Shift values by the given number of indices.
@@ -7050,14 +7039,13 @@ def shuffle(self, seed: int | None = None) -> Series:
]
"""
- @deprecate_nonkeyword_arguments(version="0.19.10")
def ewm_mean(
self,
+ *,
com: float | None = None,
span: float | None = None,
half_life: float | None = None,
alpha: float | None = None,
- *,
adjust: bool = True,
min_periods: int = 1,
ignore_nulls: bool | None = None,
@@ -7217,14 +7205,13 @@ def ewm_mean_by(
]
"""
- @deprecate_nonkeyword_arguments(version="0.19.10")
def ewm_std(
self,
+ *,
com: float | None = None,
span: float | None = None,
half_life: float | None = None,
alpha: float | None = None,
- *,
adjust: bool = True,
bias: bool = False,
min_periods: int = 1,
@@ -7302,14 +7289,13 @@ def ewm_std(
]
"""
- @deprecate_nonkeyword_arguments(version="0.19.10")
def ewm_var(
self,
+ *,
com: float | None = None,
span: float | None = None,
half_life: float | None = None,
alpha: float | None = None,
- *,
adjust: bool = True,
bias: bool = False,
min_periods: int = 1,
@@ -7531,505 +7517,6 @@ def implode(self) -> Self:
]
"""
- @deprecate_renamed_function("map_elements", version="0.19.0")
- def apply(
- self,
- function: Callable[[Any], Any],
- return_dtype: PolarsDataType | None = None,
- *,
- skip_nulls: bool = True,
- ) -> Self:
- """
- Apply a custom/user-defined function (UDF) over elements in this Series.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`Series.map_elements`.
-
- Parameters
- ----------
- function
- Custom function or lambda.
- return_dtype
- Output datatype. If none is given, the same datatype as this Series will be
- used.
- skip_nulls
- Nulls will be skipped and not passed to the python function.
- This is faster because python can be skipped and because we call
- more specialized functions.
- """
- return self.map_elements(function, return_dtype, skip_nulls=skip_nulls)
-
- @deprecate_renamed_function("rolling_map", version="0.19.0")
- def rolling_apply(
- self,
- function: Callable[[Series], Any],
- window_size: int,
- weights: list[float] | None = None,
- min_periods: int | None = None,
- *,
- center: bool = False,
- ) -> Series:
- """
- Apply a custom rolling window function.
-
- .. deprecated:: 0.19.0
- This method has been renamed to :func:`Series.rolling_map`.
-
- Parameters
- ----------
- function
- Aggregation function
- window_size
- The length of the window.
- weights
- An optional slice with the same length as the window that will be multiplied
- elementwise with the values in the window.
- min_periods
- The number of values in the window that should be non-null before computing
- a result. If None, it will be set equal to:
-
- - the window size, if `window_size` is a fixed integer
- - 1, if `window_size` is a dynamic temporal size
- center
- Set the labels at the center of the window
- """
-
- @deprecate_renamed_function("is_first_distinct", version="0.19.3")
- def is_first(self) -> Series:
- """
- Return a boolean mask indicating the first occurrence of each distinct value.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`Series.is_first_distinct`.
-
- Returns
- -------
- Series
- Series of data type :class:`Boolean`.
- """
-
- @deprecate_renamed_function("is_last_distinct", version="0.19.3")
- def is_last(self) -> Series:
- """
- Return a boolean mask indicating the last occurrence of each distinct value.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`Series.is_last_distinct`.
-
- Returns
- -------
- Series
- Series of data type :class:`Boolean`.
- """
-
- @deprecate_function("Use `clip` instead.", version="0.19.12")
- def clip_min(
- self, lower_bound: NumericLiteral | TemporalLiteral | IntoExprColumn
- ) -> Series:
- """
- Clip (limit) the values in an array to a `min` boundary.
-
- .. deprecated:: 0.19.12
- Use :func:`clip` instead.
-
- Parameters
- ----------
- lower_bound
- Lower bound.
- """
-
- @deprecate_function("Use `clip` instead.", version="0.19.12")
- def clip_max(
- self, upper_bound: NumericLiteral | TemporalLiteral | IntoExprColumn
- ) -> Series:
- """
- Clip (limit) the values in an array to a `max` boundary.
-
- .. deprecated:: 0.19.12
- Use :func:`clip` instead.
-
- Parameters
- ----------
- upper_bound
- Upper bound.
- """
-
- @deprecate_function("Use `shift` instead.", version="0.19.12")
- @deprecate_renamed_parameter("periods", "n", version="0.19.11")
- def shift_and_fill(
- self,
- fill_value: int | Expr,
- *,
- n: int = 1,
- ) -> Series:
- """
- Shift values by the given number of places and fill the resulting null values.
-
- .. deprecated:: 0.19.12
- Use :func:`shift` instead.
-
- Parameters
- ----------
- fill_value
- Fill None values with the result of this expression.
- n
- Number of places to shift (may be negative).
- """
-
- @deprecate_function("Use `Series.dtype.is_float()` instead.", version="0.19.13")
- def is_float(self) -> bool:
- """
- Check if this Series has floating point numbers.
-
- .. deprecated:: 0.19.13
- Use `Series.dtype.is_float()` instead.
-
- Examples
- --------
- >>> s = pl.Series("a", [1.0, 2.0, 3.0])
- >>> s.is_float() # doctest: +SKIP
- True
- """
- return self.dtype.is_float()
-
- @deprecate_function(
- "Use `Series.dtype.is_integer()` instead."
- " For signed/unsigned variants, use `Series.dtype.is_signed_integer()`"
- " or `Series.dtype.is_unsigned_integer()`.",
- version="0.19.13",
- )
- def is_integer(self, signed: bool | None = None) -> bool:
- """
- Check if this Series datatype is an integer (signed or unsigned).
-
- .. deprecated:: 0.19.13
- Use `Series.dtype.is_integer()` instead.
- For signed/unsigned variants, use `Series.dtype.is_signed_integer()`
- or `Series.dtype.is_unsigned_integer()`.
-
- Parameters
- ----------
- signed
- * if `None`, both signed and unsigned integer dtypes will match.
- * if `True`, only signed integer dtypes will be considered a match.
- * if `False`, only unsigned integer dtypes will be considered a match.
-
- Examples
- --------
- >>> s = pl.Series("a", [1, 2, 3], dtype=pl.UInt32)
- >>> s.is_integer() # doctest: +SKIP
- True
- >>> s.is_integer(signed=False) # doctest: +SKIP
- True
- >>> s.is_integer(signed=True) # doctest: +SKIP
- False
- """
- if signed is None:
- return self.dtype.is_integer()
- elif signed is True:
- return self.dtype.is_signed_integer()
- elif signed is False:
- return self.dtype.is_unsigned_integer()
-
- msg = f"`signed` must be None, True or False; got {signed!r}"
- raise ValueError(msg)
-
- @deprecate_function("Use `Series.dtype.is_numeric()` instead.", version="0.19.13")
- def is_numeric(self) -> bool:
- """
- Check if this Series datatype is numeric.
-
- .. deprecated:: 0.19.13
- Use `Series.dtype.is_numeric()` instead.
-
- Examples
- --------
- >>> s = pl.Series("a", [1, 2, 3])
- >>> s.is_numeric() # doctest: +SKIP
- True
- """
- return self.dtype.is_numeric()
-
- @deprecate_function("Use `Series.dtype.is_temporal()` instead.", version="0.19.13")
- def is_temporal(self, excluding: OneOrMoreDataTypes | None = None) -> bool:
- """
- Check if this Series datatype is temporal.
-
- .. deprecated:: 0.19.13
- Use `Series.dtype.is_temporal()` instead.
-
- Parameters
- ----------
- excluding
- Optionally exclude one or more temporal dtypes from matching.
-
- Examples
- --------
- >>> from datetime import date
- >>> s = pl.Series([date(2021, 1, 1), date(2021, 1, 2), date(2021, 1, 3)])
- >>> s.is_temporal() # doctest: +SKIP
- True
- >>> s.is_temporal(excluding=[pl.Date]) # doctest: +SKIP
- False
- """
- if excluding is not None:
- if not isinstance(excluding, Iterable):
- excluding = [excluding]
- if self.dtype in excluding:
- return False
-
- return self.dtype.is_temporal()
-
- @deprecate_function("Use `Series.dtype == pl.Boolean` instead.", version="0.19.14")
- def is_boolean(self) -> bool:
- """
- Check if this Series is a Boolean.
-
- .. deprecated:: 0.19.14
- Use `Series.dtype == pl.Boolean` instead.
-
- Examples
- --------
- >>> s = pl.Series("a", [True, False, True])
- >>> s.is_boolean() # doctest: +SKIP
- True
- """
- return self.dtype == Boolean
-
- @deprecate_function("Use `Series.dtype == pl.String` instead.", version="0.19.14")
- def is_utf8(self) -> bool:
- """
- Check if this Series datatype is a String.
-
- .. deprecated:: 0.19.14
- Use `Series.dtype == pl.String` instead.
-
- Examples
- --------
- >>> s = pl.Series("x", ["a", "b", "c"])
- >>> s.is_utf8() # doctest: +SKIP
- True
- """
- return self.dtype == String
-
- @deprecate_renamed_function("gather_every", version="0.19.14")
- def take_every(self, n: int, offset: int = 0) -> Series:
- """
- Take every nth value in the Series and return as new Series.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`gather_every`.
-
- Parameters
- ----------
- n
- Gather every *n*-th row.
- offset
- Starting index.
- """
- return self.gather_every(n, offset)
-
- @deprecate_renamed_function("gather", version="0.19.14")
- def take(
- self, indices: int | list[int] | Expr | Series | np.ndarray[Any, Any]
- ) -> Series:
- """
- Take values by index.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`gather`.
-
- Parameters
- ----------
- indices
- Index location used for selection.
- """
- return self.gather(indices)
-
- @deprecate_renamed_function("scatter", version="0.19.14")
- @deprecate_renamed_parameter("idx", "indices", version="0.19.14")
- @deprecate_renamed_parameter("value", "values", version="0.19.14")
- def set_at_idx(
- self,
- indices: Series | np.ndarray[Any, Any] | Sequence[int] | int,
- values: (
- int
- | float
- | str
- | bool
- | date
- | datetime
- | Sequence[int]
- | Sequence[float]
- | Sequence[bool]
- | Sequence[str]
- | Sequence[date]
- | Sequence[datetime]
- | Series
- | None
- ),
- ) -> Series:
- """
- Set values at the index locations.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`scatter`.
-
- Parameters
- ----------
- indices
- Integers representing the index locations.
- values
- Replacement values.
- """
- return self.scatter(indices, values)
-
- @deprecate_renamed_function("cum_sum", version="0.19.14")
- def cumsum(self, *, reverse: bool = False) -> Series:
- """
- Get an array with the cumulative sum computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_sum`.
-
- Parameters
- ----------
- reverse
- reverse the operation.
- """
- return self.cum_sum(reverse=reverse)
-
- @deprecate_renamed_function("cum_max", version="0.19.14")
- def cummax(self, *, reverse: bool = False) -> Series:
- """
- Get an array with the cumulative max computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_max`.
-
- Parameters
- ----------
- reverse
- reverse the operation.
- """
- return self.cum_max(reverse=reverse)
-
- @deprecate_renamed_function("cum_min", version="0.19.14")
- def cummin(self, *, reverse: bool = False) -> Series:
- """
- Get an array with the cumulative min computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_min`.
-
- Parameters
- ----------
- reverse
- reverse the operation.
- """
- return self.cum_min(reverse=reverse)
-
- @deprecate_renamed_function("cum_prod", version="0.19.14")
- def cumprod(self, *, reverse: bool = False) -> Series:
- """
- Get an array with the cumulative product computed at every element.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :meth:`cum_prod`.
-
- Parameters
- ----------
- reverse
- reverse the operation.
- """
- return self.cum_prod(reverse=reverse)
-
- @deprecate_function(
- "Use `Series.to_numpy(allow_copy=False) instead.", version="0.19.14"
- )
- def view(self, *, ignore_nulls: bool = False) -> SeriesView:
- """
- Get a view into this Series data with a numpy array.
-
- .. deprecated:: 0.19.14
- This method will be removed in a future version.
-
- This operation doesn't clone data, but does not include missing values.
- Don't use this unless you know what you are doing.
-
- Parameters
- ----------
- ignore_nulls
- If True then nulls are converted to 0.
- If False then an Exception is raised if nulls are present.
- """
- if not ignore_nulls:
- assert not self.null_count()
-
- from polars.series._numpy import SeriesView, _ptr_to_numpy
-
- ptr_type = dtype_to_ctype(self.dtype)
- ptr = self._s.as_single_ptr()
- array = _ptr_to_numpy(ptr, self.len(), ptr_type)
- array.setflags(write=False)
- return SeriesView(array, self)
-
- @deprecate_function(
- "It has been renamed to `replace`."
- " The default behavior has changed to keep any values not present in the mapping unchanged."
- " Pass `default=None` to keep existing behavior.",
- version="0.19.16",
- )
- @deprecate_renamed_parameter("remapping", "mapping", version="0.19.16")
- def map_dict(
- self,
- mapping: dict[Any, Any],
- *,
- default: Any = None,
- return_dtype: PolarsDataType | None = None,
- ) -> Self:
- """
- Replace values in the Series using a remapping dictionary.
-
- .. deprecated:: 0.19.16
- This method has been renamed to :meth:`replace`. The default behavior
- has changed to keep any values not present in the mapping unchanged.
- Pass `default=None` to keep existing behavior.
-
- Parameters
- ----------
- mapping
- Dictionary containing the before/after values to map.
- default
- Value to use when the remapping dict does not contain the lookup value.
- Use `pl.first()`, to keep the original value.
- return_dtype
- Set return dtype to override automatic return dtype determination.
- """
- return self.replace(mapping, default=default, return_dtype=return_dtype)
-
- @deprecate_renamed_function("equals", version="0.19.16")
- def series_equal(
- self, other: Series, *, null_equal: bool = True, strict: bool = False
- ) -> bool:
- """
- Check whether the Series is equal to another Series.
-
- .. deprecated:: 0.19.16
- This method has been renamed to :meth:`equals`.
-
- Parameters
- ----------
- other
- Series to compare with.
- null_equal
- Consider null values as equal.
- strict
- Don't allow different numerical dtypes, e.g. comparing `pl.UInt32` with a
- `pl.Int64` will return `False`.
- """
- return self.equals(other, check_dtypes=strict, null_equal=null_equal)
-
# Keep the `list` and `str` properties below at the end of the definition of Series,
# as to not confuse mypy with the type annotation `str` and `list`
diff --git a/py-polars/polars/series/string.py b/py-polars/polars/series/string.py
index a64649c615e3a..7f133595e44a8 100644
--- a/py-polars/polars/series/string.py
+++ b/py-polars/polars/series/string.py
@@ -2,11 +2,7 @@
from typing import TYPE_CHECKING
-from polars._utils.deprecation import (
- deprecate_function,
- deprecate_renamed_function,
- deprecate_renamed_parameter,
-)
+from polars._utils.deprecation import deprecate_function
from polars.datatypes.constants import N_INFER_DEFAULT
from polars.series.utils import expr_dispatch
@@ -1501,7 +1497,6 @@ def pad_end(self, length: int, fill_char: str = " ") -> Series:
]
"""
- @deprecate_renamed_parameter("alignment", "length", version="0.19.12")
def zfill(self, length: int | IntoExprColumn) -> Series:
"""
Pad the start of the string with zeros until it reaches the given length.
@@ -1859,169 +1854,6 @@ def to_integer(self, *, base: int = 10, strict: bool = True) -> Series:
]
"""
- @deprecate_renamed_function("to_integer", version="0.19.14")
- @deprecate_renamed_parameter("radix", "base", version="0.19.14")
- def parse_int(self, base: int | None = None, *, strict: bool = True) -> Series:
- """
- Parse integers with base radix from strings.
-
- .. deprecated:: 0.19.14
- This method has been renamed to :func:`to_integer`.
-
- Parameters
- ----------
- base
- Positive integer which is the base of the string we are parsing.
- strict
- Bool, Default=True will raise any ParseError or overflow as ComputeError.
- False silently convert to Null.
- """
-
- @deprecate_renamed_function("strip_chars", version="0.19.3")
- def strip(self, characters: str | None = None) -> Series:
- """
- Remove leading and trailing characters.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`strip_chars`.
-
- Parameters
- ----------
- characters
- The set of characters to be removed. All combinations of this set of
- characters will be stripped. If set to None (default), all whitespace is
- removed instead.
- """
-
- @deprecate_renamed_function("strip_chars_start", version="0.19.3")
- def lstrip(self, characters: str | None = None) -> Series:
- """
- Remove leading characters.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`strip_chars_start`.
-
- Parameters
- ----------
- characters
- The set of characters to be removed. All combinations of this set of
- characters will be stripped. If set to None (default), all whitespace is
- removed instead.
- """
-
- @deprecate_renamed_function("strip_chars_end", version="0.19.3")
- def rstrip(self, characters: str | None = None) -> Series:
- """
- Remove trailing characters.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`Series.strip_chars_end`.
-
- Parameters
- ----------
- characters
- The set of characters to be removed. All combinations of this set of
- characters will be stripped. If set to None (default), all whitespace is
- removed instead.
- """
-
- @deprecate_renamed_function("count_matches", version="0.19.3")
- def count_match(self, pattern: str | Series) -> Series:
- """
- Count all successive non-overlapping regex matches.
-
- .. deprecated:: 0.19.3
- This method has been renamed to :func:`count_matches`.
-
- Parameters
- ----------
- pattern
- A valid regular expression pattern, compatible with the `regex crate
- `_. Can also be a :class:`Series` of
- regular expressions.
-
- Returns
- -------
- Series
- Series of data type :class:`UInt32`. Returns null if the original
- value is null.
- """
-
- @deprecate_renamed_function("len_bytes", version="0.19.8")
- def lengths(self) -> Series:
- """
- Return the number of bytes in each string.
-
- .. deprecated:: 0.19.8
- This method has been renamed to :func:`len_bytes`.
- """
-
- @deprecate_renamed_function("len_chars", version="0.19.8")
- def n_chars(self) -> Series:
- """
- Return the length of each string as the number of characters.
-
- .. deprecated:: 0.19.8
- This method has been renamed to :func:`len_chars`.
- """
-
- @deprecate_renamed_function("pad_end", version="0.19.12")
- @deprecate_renamed_parameter("width", "length", version="0.19.12")
- def ljust(self, length: int, fill_char: str = " ") -> Series:
- """
- Return the string left justified in a string of length `length`.
-
- .. deprecated:: 0.19.12
- This method has been renamed to :func:`pad_end`.
-
- Parameters
- ----------
- length
- Justify left to this length.
- fill_char
- Fill with this ASCII character.
- """
-
- @deprecate_renamed_function("pad_start", version="0.19.12")
- @deprecate_renamed_parameter("width", "length", version="0.19.12")
- def rjust(self, length: int, fill_char: str = " ") -> Series:
- """
- Return the string right justified in a string of length `length`.
-
- .. deprecated:: 0.19.12
- This method has been renamed to :func:`pad_start`.
-
- Parameters
- ----------
- length
- Justify right to this length.
- fill_char
- Fill with this ASCII character.
- """
-
- @deprecate_renamed_function("json_decode", version="0.19.15")
- def json_extract(
- self,
- dtype: PolarsDataType | None = None,
- infer_schema_length: int | None = N_INFER_DEFAULT,
- ) -> Series:
- """
- Parse string values as JSON.
-
- .. deprecated:: 0.19.15
- This method has been renamed to :meth:`json_decode`.
-
- Parameters
- ----------
- dtype
- The dtype to cast the extracted value to. If None, the dtype will be
- inferred from the JSON value.
- infer_schema_length
- The maximum number of rows to scan for schema inference.
- If set to `None`, the full data may be scanned *(this is slow)*.
- """
- return self.json_decode(dtype, infer_schema_length)
-
def contains_any(
self, patterns: Series | list[str], *, ascii_case_insensitive: bool = False
) -> Series:
diff --git a/py-polars/polars/testing/parametric/profiles.py b/py-polars/polars/testing/parametric/profiles.py
index 9c31f7b5b9c5e..c48dd0292a668 100644
--- a/py-polars/polars/testing/parametric/profiles.py
+++ b/py-polars/polars/testing/parametric/profiles.py
@@ -5,14 +5,11 @@
from hypothesis import settings
-from polars._utils.deprecation import deprecate_nonkeyword_arguments
from polars.type_aliases import ParametricProfileNames
-@deprecate_nonkeyword_arguments(allowed_args=["profile"], version="0.19.3")
def load_profile(
- profile: ParametricProfileNames | int = "fast",
- set_environment: bool = False, # noqa: FBT001
+ profile: ParametricProfileNames | int = "fast", *, set_environment: bool = False
) -> None:
"""
Load a named (or custom) hypothesis profile for use with the parametric tests.
diff --git a/py-polars/polars/utils/__init__.py b/py-polars/polars/utils/__init__.py
deleted file mode 100644
index 6efa5aaa60c0e..0000000000000
--- a/py-polars/polars/utils/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-"""Deprecated module. Do not use."""
diff --git a/py-polars/polars/utils/udfs.py b/py-polars/polars/utils/udfs.py
deleted file mode 100644
index f7ee74e0eece4..0000000000000
--- a/py-polars/polars/utils/udfs.py
+++ /dev/null
@@ -1,43 +0,0 @@
-"""Deprecated module. Do not use."""
-
-import os
-from typing import Any
-
-from polars._utils.deprecation import deprecate_function
-
-__all__ = ["_get_shared_lib_location"]
-
-
-@deprecate_function(
- "It will be removed in the next breaking release."
- " The new `register_plugin_function` function has this functionality built in."
- " Use `from polars.plugins import register_plugin_function` to import that function."
- " Check the user guide for the currently-recommended way to register a plugin:"
- " https://docs.pola.rs/user-guide/expressions/plugins",
- version="0.20.16",
-)
-def _get_shared_lib_location(main_file: Any) -> str:
- """
- Get the location of the dynamic library file.
-
- .. deprecated:: 0.20.16
- Use :func:`polars.plugins.register_plugin_function` instead.
-
- Warnings
- --------
- This function is deprecated and will be removed in the next breaking release.
- The new `polars.plugins.register_plugin_function` function has this
- functionality built in. Use `from polars.plugins import register_plugin_function`
- to import that function.
-
- Check the user guide for the recommended way to register a plugin:
- https://docs.pola.rs/user-guide/expressions/plugins
- """
- directory = os.path.dirname(main_file) # noqa: PTH120
- return os.path.join( # noqa: PTH118
- directory, next(filter(_is_shared_lib, os.listdir(directory)))
- )
-
-
-def _is_shared_lib(file: str) -> bool:
- return file.endswith((".so", ".dll", ".pyd"))
diff --git a/py-polars/src/expr/categorical.rs b/py-polars/src/expr/categorical.rs
index c5b3971017ca1..5921b97313bfc 100644
--- a/py-polars/src/expr/categorical.rs
+++ b/py-polars/src/expr/categorical.rs
@@ -1,18 +1,9 @@
-use polars::prelude::*;
use pyo3::prelude::*;
-use crate::conversion::Wrap;
use crate::PyExpr;
#[pymethods]
impl PyExpr {
- fn cat_set_ordering(&self, ordering: Wrap) -> Self {
- self.inner
- .clone()
- .cast(DataType::Categorical(None, ordering.0))
- .into()
- }
-
fn cat_get_categories(&self) -> Self {
self.inner.clone().cat().get_categories().into()
}
diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py
index 0286bf9f8f7b2..53a93f8e0b328 100644
--- a/py-polars/tests/unit/dataframe/test_df.py
+++ b/py-polars/tests/unit/dataframe/test_df.py
@@ -292,8 +292,7 @@ def test_sort_maintain_order_descending_repeated_nulls(nulls_last: bool) -> None
def test_replace() -> None:
df = pl.DataFrame({"a": [2, 1, 3], "b": [1, 2, 3]})
s = pl.Series("c", [True, False, True])
- with pytest.deprecated_call():
- df.replace("a", s)
+ df._replace("a", s)
assert_frame_equal(df, pl.DataFrame({"a": [True, False, True], "b": [1, 2, 3]}))
diff --git a/py-polars/tests/unit/datatypes/test_categorical.py b/py-polars/tests/unit/datatypes/test_categorical.py
index a3f97877a1ea8..27da3ef92e546 100644
--- a/py-polars/tests/unit/datatypes/test_categorical.py
+++ b/py-polars/tests/unit/datatypes/test_categorical.py
@@ -509,8 +509,8 @@ def test_categorical_sort_order_by_parameter(
@StringCache()
-@pytest.mark.filterwarnings("ignore:`set_ordering` is deprecated:DeprecationWarning")
-def test_categorical_sort_order(monkeypatch: Any) -> None:
+@pytest.mark.parametrize("row_fmt_sort_enabled", [False, True])
+def test_categorical_sort_order(row_fmt_sort_enabled: bool, monkeypatch: Any) -> None:
# create the categorical ordering first
pl.Series(["foo", "bar", "baz"], dtype=pl.Categorical)
df = pl.DataFrame(
@@ -521,18 +521,14 @@ def test_categorical_sort_order(monkeypatch: Any) -> None:
}
)
- assert df.sort(["n", "x"])["x"].to_list() == ["foo", "bar", "baz"]
- assert df.with_columns(pl.col("x").cat.set_ordering("lexical")).sort(["n", "x"])[
- "x"
- ].to_list() == ["bar", "baz", "foo"]
- monkeypatch.setenv("POLARS_ROW_FMT_SORT", "1")
- assert df.sort(["n", "x"])["x"].to_list() == ["foo", "bar", "baz"]
- assert df.with_columns(pl.col("x").cat.set_ordering("lexical")).sort(["n", "x"])[
- "x"
- ].to_list() == ["bar", "baz", "foo"]
- assert df.with_columns(pl.col("x").cast(pl.Categorical("lexical"))).sort(
- ["n", "x"]
- )["x"].to_list() == ["bar", "baz", "foo"]
+ if row_fmt_sort_enabled:
+ monkeypatch.setenv("POLARS_ROW_FMT_SORT", "1")
+
+ result = df.sort(["n", "x"])
+ assert result["x"].to_list() == ["foo", "bar", "baz"]
+
+ result = df.with_columns(pl.col("x").cast(pl.Categorical("lexical"))).sort("n", "x")
+ assert result["x"].to_list() == ["bar", "baz", "foo"]
def test_err_on_categorical_asof_join_by_arg() -> None:
diff --git a/py-polars/tests/unit/datatypes/test_list.py b/py-polars/tests/unit/datatypes/test_list.py
index 0061b8e47bc6a..0d348947d8234 100644
--- a/py-polars/tests/unit/datatypes/test_list.py
+++ b/py-polars/tests/unit/datatypes/test_list.py
@@ -310,17 +310,6 @@ def test_flat_aggregation_to_list_conversion_6918() -> None:
).to_dict(as_series=False) == {"a": [1, 2], "b": [[[0.0, 1.0]], [[3.0, 4.0]]]}
-def test_list_count_matches_deprecated() -> None:
- df = pl.DataFrame({"listcol": [[], [1], [1, 2, 3, 2], [1, 2, 1], [4, 4]]})
- with pytest.deprecated_call():
- result = df.select(
- pl.col("listcol").list.count_match(2).alias("number_of_twos")
- )
-
- expected = {"number_of_twos": [0, 0, 2, 1, 0]}
- assert result.to_dict(as_series=False) == expected
-
-
def test_list_count_matches() -> None:
assert pl.DataFrame({"listcol": [[], [1], [1, 2, 3, 2], [1, 2, 1], [4, 4]]}).select(
pl.col("listcol").list.count_matches(2).alias("number_of_twos")
diff --git a/py-polars/tests/unit/datatypes/test_struct.py b/py-polars/tests/unit/datatypes/test_struct.py
index 13fd6dab253c3..285f29a3babb7 100644
--- a/py-polars/tests/unit/datatypes/test_struct.py
+++ b/py-polars/tests/unit/datatypes/test_struct.py
@@ -86,8 +86,6 @@ def test_struct_equality_strict() -> None:
# strict
assert s1.is_(s2) is False
- with pytest.deprecated_call():
- assert s1.is_not(s2) is True
# permissive (default)
assert s1 == s2
diff --git a/py-polars/tests/unit/expr/test_exprs.py b/py-polars/tests/unit/expr/test_exprs.py
index 49fa0e318e5a0..e51231490e70c 100644
--- a/py-polars/tests/unit/expr/test_exprs.py
+++ b/py-polars/tests/unit/expr/test_exprs.py
@@ -697,17 +697,6 @@ def test_tail() -> None:
}
-def test_is_not_deprecated() -> None:
- df = pl.DataFrame({"a": [True, False, True]})
-
- with pytest.deprecated_call():
- expr = pl.col("a").is_not()
- result = df.select(expr)
-
- expected = pl.DataFrame({"a": [False, True, False]})
- assert_frame_equal(result, expected)
-
-
def test_repr_short_expression() -> None:
expr = pl.functions.all().len().name.prefix("length:")
# we cut off the last ten characters because that includes the
diff --git a/py-polars/tests/unit/functions/test_cum_count.py b/py-polars/tests/unit/functions/test_cum_count.py
index b68db3678ab9e..b55f788812a1a 100644
--- a/py-polars/tests/unit/functions/test_cum_count.py
+++ b/py-polars/tests/unit/functions/test_cum_count.py
@@ -81,18 +81,6 @@ def test_cum_count() -> None:
assert out["foo"][1].to_list() == [1, 2]
-def test_cumcount_deprecated() -> None:
- df = pl.DataFrame([["a"], ["a"], ["a"], ["b"], ["b"], ["a"]], schema=["A"])
-
- with pytest.deprecated_call():
- out = df.group_by("A", maintain_order=True).agg(
- pl.col("A").cumcount().alias("foo")
- )
-
- assert out["foo"][0].to_list() == [1, 2, 3, 4]
- assert out["foo"][1].to_list() == [1, 2]
-
-
def test_series_cum_count() -> None:
s = pl.Series(["x", "k", None, "d"])
result = s.cum_count()
diff --git a/py-polars/tests/unit/interop/numpy/test_to_numpy_series.py b/py-polars/tests/unit/interop/numpy/test_to_numpy_series.py
index a8bdea51feddd..679d0a6579b82 100644
--- a/py-polars/tests/unit/interop/numpy/test_to_numpy_series.py
+++ b/py-polars/tests/unit/interop/numpy/test_to_numpy_series.py
@@ -461,36 +461,3 @@ def test_to_numpy2(
# As Null values can't be encoded natively in a numpy array,
# this array will never be a view.
assert np_array_with_missing_values.flags.writeable == writable
-
-
-def test_view() -> None:
- s = pl.Series("a", [1.0, 2.5, 3.0])
- with pytest.deprecated_call():
- result = s.view()
- assert isinstance(result, np.ndarray)
- assert np.all(result == np.array([1.0, 2.5, 3.0]))
-
-
-def test_view_nulls() -> None:
- s = pl.Series("b", [1, 2, None])
- assert s.has_nulls()
- with pytest.deprecated_call(), pytest.raises(AssertionError):
- s.view()
-
-
-def test_view_nulls_sliced() -> None:
- s = pl.Series("b", [1, 2, None])
- sliced = s[:2]
- with pytest.deprecated_call():
- view = sliced.view()
- assert np.all(view == np.array([1, 2]))
- with pytest.deprecated_call():
- assert not sliced.has_validity()
-
-
-def test_view_ub() -> None:
- # this would be UB if the series was dropped and not passed to the view
- s = pl.Series([3, 1, 5])
- with pytest.deprecated_call():
- result = s.sort().view()
- assert np.sum(result) == 9
diff --git a/py-polars/tests/unit/operations/aggregation/test_aggregations.py b/py-polars/tests/unit/operations/aggregation/test_aggregations.py
index c94723c92d32c..6642a35f4aa14 100644
--- a/py-polars/tests/unit/operations/aggregation/test_aggregations.py
+++ b/py-polars/tests/unit/operations/aggregation/test_aggregations.py
@@ -304,7 +304,7 @@ def test_horizontal_sum_bool_dtype() -> None:
assert_frame_equal(out, pl.DataFrame({"a": pl.Series([1, 0], dtype=pl.UInt32)}))
-def test_horizontal_sum_in_groupby_15102() -> None:
+def test_horizontal_sum_in_group_by_15102() -> None:
nbr_records = 1000
out = (
pl.LazyFrame(
@@ -504,7 +504,7 @@ def test_horizontal_mean_single_column(
assert_frame_equal(out, pl.DataFrame({"a": pl.Series([1.0, 0.0], dtype=out_dtype)}))
-def test_horizontal_mean_in_groupby_15115() -> None:
+def test_horizontal_mean_in_group_by_15115() -> None:
nbr_records = 1000
out = (
pl.LazyFrame(
diff --git a/py-polars/tests/unit/operations/aggregation/test_horizontal.py b/py-polars/tests/unit/operations/aggregation/test_horizontal.py
index 4739c1698c53e..0596b73417d2a 100644
--- a/py-polars/tests/unit/operations/aggregation/test_horizontal.py
+++ b/py-polars/tests/unit/operations/aggregation/test_horizontal.py
@@ -311,20 +311,6 @@ def test_cum_sum_horizontal() -> None:
assert_frame_equal(result, expected)
-def test_cumsum_horizontal_deprecated() -> None:
- df = pl.DataFrame(
- {
- "a": [1, 2],
- "b": [3, 4],
- "c": [5, 6],
- }
- )
- with pytest.deprecated_call():
- result = df.select(pl.cumsum_horizontal("a", "c"))
- expected = df = pl.DataFrame({"cumsum": [{"a": 1, "c": 6}, {"a": 2, "c": 8}]})
- assert_frame_equal(result, expected)
-
-
def test_sum_dtype_12028() -> None:
result = pl.select(
pl.sum_horizontal([pl.duration(seconds=10)]).alias("sum_duration")
diff --git a/py-polars/tests/unit/operations/map/test_map_batches.py b/py-polars/tests/unit/operations/map/test_map_batches.py
index e4929a6cb13ea..127f1079b0602 100644
--- a/py-polars/tests/unit/operations/map/test_map_batches.py
+++ b/py-polars/tests/unit/operations/map/test_map_batches.py
@@ -74,15 +74,6 @@ def test_map_batches_group() -> None:
).sort("id").to_dict(as_series=False) == {"id": [0, 1], "t": [11, 35]}
-def test_map_deprecated() -> None:
- with pytest.deprecated_call():
- pl.map(["a", "b"], lambda x: x[0])
- with pytest.deprecated_call():
- pl.col("a").map(lambda x: x)
- with pytest.deprecated_call():
- pl.LazyFrame({"a": [1, 2]}).map(lambda x: x)
-
-
def test_ufunc_args() -> None:
df = pl.DataFrame({"a": [1, 2, 3], "b": [2, 4, 6]})
result = df.select(
diff --git a/py-polars/tests/unit/operations/map/test_map_elements.py b/py-polars/tests/unit/operations/map/test_map_elements.py
index a4f1690bae526..19016ce462b48 100644
--- a/py-polars/tests/unit/operations/map/test_map_elements.py
+++ b/py-polars/tests/unit/operations/map/test_map_elements.py
@@ -342,13 +342,6 @@ def test_map_elements_chunked_14390() -> None:
)
-def test_apply_deprecated() -> None:
- with pytest.deprecated_call():
- pl.col("a").apply(np.abs)
- with pytest.deprecated_call():
- pl.Series([1, 2, 3]).apply(np.abs, return_dtype=pl.Float64)
-
-
def test_cabbage_strategy_14396() -> None:
df = pl.DataFrame({"x": [1, 2, 3]})
with pytest.raises(
diff --git a/py-polars/tests/unit/operations/map/test_map_groups.py b/py-polars/tests/unit/operations/map/test_map_groups.py
index 315aadf50e570..400ba5e0a05d0 100644
--- a/py-polars/tests/unit/operations/map/test_map_groups.py
+++ b/py-polars/tests/unit/operations/map/test_map_groups.py
@@ -147,21 +147,3 @@ def test_map_groups_numpy_output_3057() -> None:
expected = pl.DataFrame({"id": [0, 1], "result": [1.955, 13.0]})
assert_frame_equal(result, expected)
-
-
-def test_apply_deprecated() -> None:
- df = pl.DataFrame(
- {
- "a": [1, 1, 2, 2, 3],
- "b": [1, 2, 3, 4, 5],
- }
- ).set_sorted("a")
-
- with pytest.deprecated_call():
- df.group_by("a").apply(lambda x: x)
- with pytest.deprecated_call():
- df.rolling("a", period="2i").apply(lambda x: x, schema=None)
- with pytest.deprecated_call():
- df.group_by_dynamic("a", every="2i").apply(lambda x: x, schema=None)
- with pytest.deprecated_call():
- pl.apply(["a", "b"], lambda x: x)
diff --git a/py-polars/tests/unit/operations/map/test_map_rows.py b/py-polars/tests/unit/operations/map/test_map_rows.py
index bb53dfa64262d..8c5d76f260d0a 100644
--- a/py-polars/tests/unit/operations/map/test_map_rows.py
+++ b/py-polars/tests/unit/operations/map/test_map_rows.py
@@ -66,13 +66,3 @@ def test_map_rows_shifted_chunks() -> None:
}
)
assert_frame_equal(result, expected)
-
-
-def test_apply_deprecated() -> None:
- df = pl.DataFrame({"a": ["foo", "2"], "b": [1, 2], "c": [1.0, 2.0]})
-
- with pytest.deprecated_call():
- result = df.apply(lambda x: len(x), None)
-
- expected = pl.DataFrame({"map": [3, 3]})
- assert_frame_equal(result, expected)
diff --git a/py-polars/tests/unit/operations/namespaces/list/test_list.py b/py-polars/tests/unit/operations/namespaces/list/test_list.py
index bf88dc8bd976e..2b66a6249fa73 100644
--- a/py-polars/tests/unit/operations/namespaces/list/test_list.py
+++ b/py-polars/tests/unit/operations/namespaces/list/test_list.py
@@ -730,14 +730,6 @@ def test_list_len() -> None:
assert_series_equal(result, expected)
-def test_list_lengths_deprecated() -> None:
- s = pl.Series([[1, 2, None], [5]])
- with pytest.deprecated_call():
- result = s.list.lengths()
- expected = pl.Series([3, 1], dtype=pl.UInt32)
- assert_series_equal(result, expected)
-
-
def test_list_to_array() -> None:
data = [[1.0, 2.0], [3.0, 4.0]]
s = pl.Series(data, dtype=pl.List(pl.Float32))
diff --git a/py-polars/tests/unit/operations/namespaces/string/test_pad.py b/py-polars/tests/unit/operations/namespaces/string/test_pad.py
index 7364cf5fb9bae..06df899e41ff8 100644
--- a/py-polars/tests/unit/operations/namespaces/string/test_pad.py
+++ b/py-polars/tests/unit/operations/namespaces/string/test_pad.py
@@ -1,9 +1,7 @@
from __future__ import annotations
-import pytest
-
import polars as pl
-from polars.testing import assert_frame_equal, assert_series_equal
+from polars.testing import assert_frame_equal
def test_str_pad_start() -> None:
@@ -90,26 +88,6 @@ def test_str_zfill_expr() -> None:
assert_frame_equal(out, expected)
-def test_str_ljust_deprecated() -> None:
- s = pl.Series(["a", "bc", "def"])
-
- with pytest.deprecated_call():
- result = s.str.ljust(5)
-
- expected = pl.Series(["a ", "bc ", "def "])
- assert_series_equal(result, expected)
-
-
-def test_str_rjust_deprecated() -> None:
- s = pl.Series(["a", "bc", "def"])
-
- with pytest.deprecated_call():
- result = s.str.rjust(5)
-
- expected = pl.Series([" a", " bc", " def"])
- assert_series_equal(result, expected)
-
-
def test_pad_end_unicode() -> None:
lf = pl.LazyFrame({"a": ["Café", "345", "東京", None]})
diff --git a/py-polars/tests/unit/operations/namespaces/string/test_string.py b/py-polars/tests/unit/operations/namespaces/string/test_string.py
index a2c7261a27772..b19920a958a51 100644
--- a/py-polars/tests/unit/operations/namespaces/string/test_string.py
+++ b/py-polars/tests/unit/operations/namespaces/string/test_string.py
@@ -191,14 +191,6 @@ def test_str_len_bytes() -> None:
assert_series_equal(result, expected)
-def test_str_lengths_deprecated() -> None:
- s = pl.Series(["Café", None, "345", "東京"])
- with pytest.deprecated_call():
- result = s.str.lengths()
- expected = pl.Series([5, None, 3, 6], dtype=pl.UInt32)
- assert_series_equal(result, expected)
-
-
def test_str_len_chars() -> None:
s = pl.Series(["Café", None, "345", "東京"])
result = s.str.len_chars()
@@ -206,14 +198,6 @@ def test_str_len_chars() -> None:
assert_series_equal(result, expected)
-def test_str_n_chars_deprecated() -> None:
- s = pl.Series(["Café", None, "345", "東京"])
- with pytest.deprecated_call():
- result = s.str.n_chars()
- expected = pl.Series([4, None, 3, 2], dtype=pl.UInt32)
- assert_series_equal(result, expected)
-
-
def test_str_contains() -> None:
s = pl.Series(["messi", "ronaldo", "ibrahimovic"])
expected = pl.Series([True, False, False])
@@ -471,14 +455,6 @@ def test_str_to_integer_base_literal() -> None:
)
-def test_str_parse_int_deprecated() -> None:
- s = pl.Series(["110", "101", "010"])
- with pytest.deprecated_call(match="It has been renamed to `to_integer`"):
- result = s.str.parse_int()
- expected = pl.Series([6, 5, 2], dtype=pl.Int32)
- assert_series_equal(result, expected)
-
-
def test_str_strip_chars_expr() -> None:
df = pl.DataFrame(
{
@@ -571,22 +547,6 @@ def test_str_strip_whitespace() -> None:
assert_series_equal(s.str.strip_chars(), expected)
-def test_str_strip_deprecated() -> None:
- with pytest.deprecated_call():
- pl.col("a").str.strip()
- with pytest.deprecated_call():
- pl.col("a").str.lstrip()
- with pytest.deprecated_call():
- pl.col("a").str.rstrip()
-
- with pytest.deprecated_call():
- pl.Series(["a", "b", "c"]).str.strip()
- with pytest.deprecated_call():
- pl.Series(["a", "b", "c"]).str.lstrip()
- with pytest.deprecated_call():
- pl.Series(["a", "b", "c"]).str.rstrip()
-
-
def test_str_strip_prefix_literal() -> None:
s = pl.Series(["foo:bar", "foofoo:bar", "bar:bar", "foo", "", None])
expected = pl.Series([":bar", "foo:bar", "bar:bar", "", "", None])
@@ -708,14 +668,6 @@ def test_json_decode_nested_struct() -> None:
assert_series_equal(key_1_values.get_column("key_1_values"), expected_values)
-def test_json_extract_deprecated() -> None:
- s = pl.Series(['{"a": 1, "b": true}', None, '{"a": 2, "b": false}'])
- expected = pl.Series([{"a": 1, "b": True}, None, {"a": 2, "b": False}])
- with pytest.deprecated_call():
- result = s.str.json_extract()
- assert_series_equal(result, expected)
-
-
def test_json_decode_primitive_to_list_11053() -> None:
df = pl.DataFrame(
{
@@ -1035,18 +987,6 @@ def test_extract_all_count() -> None:
assert df["foo"].str.count_matches(r"a").dtype == pl.UInt32
-def test_count_matches_deprecated_count() -> None:
- df = pl.DataFrame({"foo": ["123 bla 45 asd", "xaz 678 910t", "boo", None]})
-
- with pytest.deprecated_call():
- expr = pl.col("foo").str.count_match(r"a")
-
- result = df.select(expr)
-
- expected = pl.Series("foo", [2, 1, 0, None], dtype=pl.UInt32).to_frame()
- assert_frame_equal(result, expected)
-
-
def test_count_matches_many() -> None:
df = pl.DataFrame(
{
diff --git a/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py b/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py
index 96b27b814d650..f2eed19af83e6 100644
--- a/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py
+++ b/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py
@@ -450,32 +450,6 @@ def test_duration_extract_times(
assert_series_equal(getattr(duration.dt, unit_attr)(), expected)
-@pytest.mark.parametrize(
- ("unit_attr", "expected"),
- [
- ("days", pl.Series([1])),
- ("hours", pl.Series([24])),
- ("minutes", pl.Series([24 * 60])),
- ("seconds", pl.Series([3600 * 24])),
- ("milliseconds", pl.Series([3600 * 24 * int(1e3)])),
- ("microseconds", pl.Series([3600 * 24 * int(1e6)])),
- ("nanoseconds", pl.Series([3600 * 24 * int(1e9)])),
- ],
-)
-def test_duration_extract_times_deprecated_methods(
- unit_attr: str,
- expected: pl.Series,
-) -> None:
- duration = pl.Series([datetime(2022, 1, 2)]) - pl.Series([datetime(2022, 1, 1)])
-
- with pytest.deprecated_call():
- assert_series_equal(getattr(duration.dt, unit_attr)(), expected)
- with pytest.deprecated_call():
- # Test Expr case too
- result_df = pl.select(getattr(pl.lit(duration).dt, unit_attr)())
- assert_series_equal(result_df[result_df.columns[0]], expected)
-
-
@pytest.mark.parametrize(
("time_unit", "every"),
[
diff --git a/py-polars/tests/unit/operations/rolling/test_map.py b/py-polars/tests/unit/operations/rolling/test_map.py
index d711ad752523d..789940efde2ae 100644
--- a/py-polars/tests/unit/operations/rolling/test_map.py
+++ b/py-polars/tests/unit/operations/rolling/test_map.py
@@ -126,10 +126,3 @@ def test_rolling_map_rolling_std() -> None:
expected = s.rolling_std(window_size=4, min_periods=3, center=False)
assert_series_equal(result, expected)
-
-
-def test_rolling_apply_deprecated() -> None:
- with pytest.deprecated_call():
- pl.col("a").rolling_apply(lambda x: x + 1, window_size=2)
- with pytest.deprecated_call():
- pl.Series([1, 2, 3]).rolling_apply(lambda x: x + 1, window_size=2)
diff --git a/py-polars/tests/unit/operations/test_clip.py b/py-polars/tests/unit/operations/test_clip.py
index 360ad617b78ae..d95c4a3bc8c60 100644
--- a/py-polars/tests/unit/operations/test_clip.py
+++ b/py-polars/tests/unit/operations/test_clip.py
@@ -5,7 +5,7 @@
import pytest
import polars as pl
-from polars.testing import assert_frame_equal, assert_series_equal
+from polars.testing import assert_frame_equal
@pytest.fixture()
@@ -135,17 +135,3 @@ def test_clip_bound_invalid_for_original_dtype() -> None:
s = pl.Series([1, 2, 3, 4], dtype=pl.UInt32)
with pytest.raises(pl.ComputeError, match="conversion from `i32` to `u32` failed"):
s.clip(-1, 5)
-
-
-def test_clip_min_max_deprecated() -> None:
- s = pl.Series([-1, 0, 1])
-
- with pytest.deprecated_call():
- result = s.clip_min(0)
- expected = pl.Series([0, 0, 1])
- assert_series_equal(result, expected)
-
- with pytest.deprecated_call():
- result = s.clip_max(0)
- expected = pl.Series([-1, 0, 0])
- assert_series_equal(result, expected)
diff --git a/py-polars/tests/unit/operations/test_group_by.py b/py-polars/tests/unit/operations/test_group_by.py
index 14be709035ff8..38d7fb1ceb205 100644
--- a/py-polars/tests/unit/operations/test_group_by.py
+++ b/py-polars/tests/unit/operations/test_group_by.py
@@ -776,69 +776,6 @@ def test_group_by_series_partitioned(partition_limit: int) -> None:
df.group_by(groups).agg(pl.all().is_not_null().sum())
-def test_groupby_deprecated() -> None:
- df = pl.DataFrame({"a": [1, 1, 2], "b": [3, 4, 5]})
-
- with pytest.deprecated_call():
- result = df.groupby("a").agg(pl.sum("b"))
- with pytest.deprecated_call():
- result_lazy = df.lazy().groupby("a").agg(pl.sum("b")).collect()
-
- expected = df.group_by("a").agg(pl.sum("b"))
- assert_frame_equal(result, expected, check_row_order=False)
- assert_frame_equal(result_lazy, expected, check_row_order=False)
-
-
-def test_groupby_rolling_deprecated() -> None:
- df = pl.DataFrame(
- {
- "date": pl.datetime_range(
- datetime(2020, 1, 1), datetime(2020, 1, 5), eager=True
- ),
- "value": [1, 2, 3, 4, 5],
- }
- )
-
- with pytest.deprecated_call():
- result = df.groupby_rolling("date", period="2d").agg(pl.sum("value"))
- with pytest.deprecated_call():
- result_lazy = (
- df.lazy()
- .groupby_rolling("date", period="2d")
- .agg(pl.sum("value"))
- .collect()
- )
-
- expected = df.rolling("date", period="2d").agg(pl.sum("value"))
- assert_frame_equal(result, expected, check_row_order=False)
- assert_frame_equal(result_lazy, expected, check_row_order=False)
-
-
-def test_group_by_rolling_deprecated() -> None:
- df = pl.DataFrame(
- {
- "date": pl.datetime_range(
- datetime(2020, 1, 1), datetime(2020, 1, 5), eager=True
- ),
- "value": [1, 2, 3, 4, 5],
- }
- )
-
- with pytest.deprecated_call():
- result = df.group_by_rolling("date", period="2d").agg(pl.sum("value"))
- with pytest.deprecated_call():
- result_lazy = (
- df.lazy()
- .groupby_rolling("date", period="2d")
- .agg(pl.sum("value"))
- .collect()
- )
-
- expected = df.rolling("date", period="2d").agg(pl.sum("value"))
- assert_frame_equal(result, expected, check_row_order=False)
- assert_frame_equal(result_lazy, expected, check_row_order=False)
-
-
def test_group_by_list_scalar_11749() -> None:
df = pl.DataFrame(
{
diff --git a/py-polars/tests/unit/operations/test_group_by_dynamic.py b/py-polars/tests/unit/operations/test_group_by_dynamic.py
index c75c2e1d58f1e..83b9e99c38ed5 100644
--- a/py-polars/tests/unit/operations/test_group_by_dynamic.py
+++ b/py-polars/tests/unit/operations/test_group_by_dynamic.py
@@ -378,28 +378,6 @@ def test_rolling_dynamic_sortedness_check() -> None:
df.group_by_dynamic("idx", every="2i").agg(pl.col("idx").alias("idx1"))
-def test_groupby_dynamic_deprecated() -> None:
- df = pl.DataFrame(
- {
- "date": pl.datetime_range(
- datetime(2020, 1, 1), datetime(2020, 1, 5), eager=True
- ),
- "value": [1, 2, 3, 4, 5],
- }
- )
-
- with pytest.deprecated_call():
- result = df.groupby_dynamic("date", every="2d").agg(pl.sum("value"))
- with pytest.deprecated_call():
- result_lazy = (
- df.lazy().groupby_dynamic("date", every="2d").agg(pl.sum("value")).collect()
- )
-
- expected = df.group_by_dynamic("date", every="2d").agg(pl.sum("value"))
- assert_frame_equal(result, expected, check_row_order=False)
- assert_frame_equal(result_lazy, expected, check_row_order=False)
-
-
@pytest.mark.parametrize("time_zone", [None, "UTC", "Asia/Kathmandu"])
def test_group_by_dynamic_elementwise_following_mean_agg_6904(
time_zone: str | None,
diff --git a/py-polars/tests/unit/operations/test_is_first_last_distinct.py b/py-polars/tests/unit/operations/test_is_first_last_distinct.py
index f5d69b97557d7..99024f08a8207 100644
--- a/py-polars/tests/unit/operations/test_is_first_last_distinct.py
+++ b/py-polars/tests/unit/operations/test_is_first_last_distinct.py
@@ -152,10 +152,3 @@ def test_is_first_last_distinct_all_null(dtypes: pl.PolarsDataType) -> None:
s = pl.Series([None, None, None], dtype=dtypes)
assert s.is_first_distinct().to_list() == [True, False, False]
assert s.is_last_distinct().to_list() == [False, False, True]
-
-
-def test_is_first_last_deprecated() -> None:
- with pytest.deprecated_call():
- pl.col("a").is_first()
- with pytest.deprecated_call():
- pl.col("a").is_last()
diff --git a/py-polars/tests/unit/operations/test_pivot.py b/py-polars/tests/unit/operations/test_pivot.py
index 0607583f82d44..cf71597fe30c7 100644
--- a/py-polars/tests/unit/operations/test_pivot.py
+++ b/py-polars/tests/unit/operations/test_pivot.py
@@ -421,18 +421,6 @@ def test_aggregate_function_default() -> None:
df.pivot(index="b", columns="c", values="a")
-def test_pivot_positional_args_deprecated() -> None:
- df = pl.DataFrame(
- {
- "foo": ["A", "A", "B", "B", "C"],
- "N": [1, 2, 2, 4, 2],
- "bar": ["k", "l", "m", "n", "o"],
- }
- )
- with pytest.deprecated_call():
- df.pivot("N", "foo", "bar", aggregate_function=None)
-
-
def test_pivot_aggregate_function_count_deprecated() -> None:
df = pl.DataFrame(
{
diff --git a/py-polars/tests/unit/operations/test_replace.py b/py-polars/tests/unit/operations/test_replace.py
index cd5f80a73364b..f9fc424dd1da0 100644
--- a/py-polars/tests/unit/operations/test_replace.py
+++ b/py-polars/tests/unit/operations/test_replace.py
@@ -507,18 +507,6 @@ def test_replace_duplicates_new() -> None:
assert_series_equal(result, expected)
-def test_map_dict_deprecated() -> None:
- s = pl.Series("a", [1, 2, 3])
- with pytest.deprecated_call():
- result = s.map_dict({2: 100})
- expected = pl.Series("a", [None, 100, None])
- assert_series_equal(result, expected)
-
- with pytest.deprecated_call():
- result = s.to_frame().select(pl.col("a").map_dict({2: 100})).to_series()
- assert_series_equal(result, expected)
-
-
@pytest.mark.parametrize(
("context", "dtype"),
[
diff --git a/py-polars/tests/unit/operations/test_shift.py b/py-polars/tests/unit/operations/test_shift.py
index 2979c125b7e24..d10a4d38bf1a1 100644
--- a/py-polars/tests/unit/operations/test_shift.py
+++ b/py-polars/tests/unit/operations/test_shift.py
@@ -2,8 +2,6 @@
from datetime import date
-import pytest
-
import polars as pl
from polars.testing import assert_frame_equal, assert_series_equal
@@ -40,7 +38,7 @@ def test_shift_frame(fruits_cars: pl.DataFrame) -> None:
assert res[rows, cols] is None
-def test_shift_and_fill() -> None:
+def test_shift_fill_value() -> None:
ldf = pl.LazyFrame({"a": [1, 2, 3, 4, 5], "b": [1, 2, 3, 4, 5]})
# use exprs
@@ -103,7 +101,7 @@ def test_shift_frame_with_fill() -> None:
assert_frame_equal(result, expected)
-def test_shift_and_fill_group_logicals() -> None:
+def test_shift_fill_value_group_logicals() -> None:
df = pl.DataFrame(
[
(date(2001, 1, 2), "A"),
@@ -117,23 +115,3 @@ def test_shift_and_fill_group_logicals() -> None:
result = df.select(pl.col("d").shift(fill_value=pl.col("d").max(), n=-1).over("s"))
assert result.dtypes == [pl.Date]
-
-
-def test_shift_and_fill_deprecated() -> None:
- a = pl.Series("a", [1, 2, 3])
-
- with pytest.deprecated_call():
- result = a.shift_and_fill(100, n=-1)
-
- expected = pl.Series("a", [2, 3, 100])
- assert_series_equal(result, expected)
-
-
-def test_shift_and_fill_frame_deprecated() -> None:
- lf = pl.LazyFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
-
- with pytest.deprecated_call():
- result = lf.shift_and_fill(100, n=1)
-
- expected = pl.LazyFrame({"a": [100, 1, 2], "b": [100, 4, 5]})
- assert_frame_equal(result, expected)
diff --git a/py-polars/tests/unit/series/test_scatter.py b/py-polars/tests/unit/series/test_scatter.py
index 7f1ce565a8969..72ab03814671c 100644
--- a/py-polars/tests/unit/series/test_scatter.py
+++ b/py-polars/tests/unit/series/test_scatter.py
@@ -53,14 +53,6 @@ def test_scatter() -> None:
a[-100] = None
-def test_set_at_idx_deprecated() -> None:
- s = pl.Series("s", [1, 2, 3])
- with pytest.deprecated_call():
- result = s.set_at_idx(1, 10)
- expected = pl.Series("s", [1, 10, 3])
- assert_series_equal(result, expected)
-
-
def test_scatter_datetime() -> None:
s = pl.Series("dt", [None, datetime(2024, 1, 31)])
result = s.scatter(0, datetime(2022, 2, 2))
diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py
index a405a08dc47ac..597608a61564d 100644
--- a/py-polars/tests/unit/series/test_series.py
+++ b/py-polars/tests/unit/series/test_series.py
@@ -58,19 +58,6 @@ def test_cum_agg_with_nulls() -> None:
assert_series_equal(s.cum_prod(), pl.Series("a", [None, 2, None, 14, 112, None]))
-def test_cum_agg_deprecated() -> None:
- # confirm that known series give expected results
- s = pl.Series("a", [1, 2, 3, 2])
- with pytest.deprecated_call():
- assert_series_equal(s.cumsum(), pl.Series("a", [1, 3, 6, 8]))
- with pytest.deprecated_call():
- assert_series_equal(s.cummin(), pl.Series("a", [1, 1, 1, 1]))
- with pytest.deprecated_call():
- assert_series_equal(s.cummax(), pl.Series("a", [1, 2, 3, 3]))
- with pytest.deprecated_call():
- assert_series_equal(s.cumprod(), pl.Series("a", [1, 2, 6, 12]))
-
-
def test_init_inputs(monkeypatch: Any) -> None:
nan = float("nan")
# Good inputs
@@ -606,10 +593,8 @@ def test_series_dtype_is() -> None:
assert not s.dtype.is_numeric()
s = pl.Series("s", ["testing..."])
- with pytest.deprecated_call():
- assert s.is_utf8() is True
- with pytest.deprecated_call():
- assert s.is_boolean() is False
+ assert s.dtype == pl.String
+ assert s.dtype != pl.Boolean
s = pl.Series("s", [], dtype=pl.Decimal(20, 15))
assert not s.dtype.is_float()
@@ -620,18 +605,6 @@ def test_series_dtype_is() -> None:
assert s.dtype.is_temporal()
-def test_series_is_dtype_deprecated() -> None:
- s = pl.Series([1.0, 2.0])
- with pytest.deprecated_call():
- assert s.is_float() is True
- with pytest.deprecated_call():
- assert s.is_numeric() is True
- with pytest.deprecated_call():
- assert s.is_integer() is False
- with pytest.deprecated_call():
- assert s.is_temporal() is False
-
-
def test_series_head_tail_limit() -> None:
s = pl.Series(range(10))
diff --git a/py-polars/tests/unit/sql/test_miscellaneous.py b/py-polars/tests/unit/sql/test_miscellaneous.py
index 7f37e20bdda39..c1f729161e32b 100644
--- a/py-polars/tests/unit/sql/test_miscellaneous.py
+++ b/py-polars/tests/unit/sql/test_miscellaneous.py
@@ -5,7 +5,6 @@
import pytest
import polars as pl
-from polars.exceptions import SQLInterfaceError
from polars.testing import assert_frame_equal
@@ -82,7 +81,7 @@ def test_distinct() -> None:
# test unregistration
ctx.unregister("df")
- with pytest.raises(SQLInterfaceError, match="relation 'df' was not found"):
+ with pytest.raises(pl.SQLInterfaceError, match="relation 'df' was not found"):
ctx.execute("SELECT * FROM df")
@@ -95,7 +94,7 @@ def test_frame_sql_globals_error() -> None:
FROM df2 JOIN df1 ON df1.a = df2.a
ORDER BY b DESC
"""
- with pytest.raises(SQLInterfaceError, match=".*not found.*"):
+ with pytest.raises(pl.SQLInterfaceError, match=".*not found.*"):
df1.sql(query=query)
res = pl.sql(query=query, eager=True)
diff --git a/py-polars/tests/unit/streaming/test_streaming_group_by.py b/py-polars/tests/unit/streaming/test_streaming_group_by.py
index c7f22f357eea2..5e18040db3983 100644
--- a/py-polars/tests/unit/streaming/test_streaming_group_by.py
+++ b/py-polars/tests/unit/streaming/test_streaming_group_by.py
@@ -455,7 +455,7 @@ def test_streaming_group_null_count() -> None:
) == {"g": [1], "a": [3]}
-def test_streaming_groupby_binary_15116() -> None:
+def test_streaming_group_by_binary_15116() -> None:
assert (
pl.LazyFrame(
{
diff --git a/py-polars/tests/unit/test_lazy.py b/py-polars/tests/unit/test_lazy.py
index 72ea8b7a387b9..c6d5d69e3952b 100644
--- a/py-polars/tests/unit/test_lazy.py
+++ b/py-polars/tests/unit/test_lazy.py
@@ -507,30 +507,6 @@ def test_cum_agg() -> None:
)
-def test_cum_agg_deprecated() -> None:
- ldf = pl.LazyFrame({"a": [1, 2, 3, 2]})
- with pytest.deprecated_call():
- assert_series_equal(
- ldf.select(pl.col("a").cumsum()).collect()["a"],
- pl.Series("a", [1, 3, 6, 8]),
- )
- with pytest.deprecated_call():
- assert_series_equal(
- ldf.select(pl.col("a").cummin()).collect()["a"],
- pl.Series("a", [1, 1, 1, 1]),
- )
- with pytest.deprecated_call():
- assert_series_equal(
- ldf.select(pl.col("a").cummax()).collect()["a"],
- pl.Series("a", [1, 2, 3, 3]),
- )
- with pytest.deprecated_call():
- assert_series_equal(
- ldf.select(pl.col("a").cumprod()).collect()["a"],
- pl.Series("a", [1, 2, 6, 12]),
- )
-
-
def test_floor() -> None:
ldf = pl.LazyFrame({"a": [1.8, 1.2, 3.0]}).select(pl.col("a").floor())
assert_series_equal(ldf.collect()["a"], pl.Series("a", [1, 1, 3]).cast(pl.Float64))