Repository: pandas-dev/pandas

Issue:
DOC/DEPR: sep vs pat in series.str.partition
All the way back to the v0.16 docs, `Series.str.partition` (https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.partition.html) has the signature ```Series.str.partition(pat=' ', expand=True)```, but the docs only talk about `sep` instead of `pat`.
![3](https://user-images.githubusercontent.com/33685575/45404837-d4511780-b660-11e8-865f-e64bd2f47852.png)

I think the kwarg should be renamed to `sep`, which makes more sense for partitioning something than `pat`, which sounds like it's about a regex pattern.

Same thing applies to `rpartition`.



Discussion:
It is standard method https://docs.python.org/3/library/stdtypes.html#str.partition
The parameter is named `sep` there, but in Pandas implementation it is `pat`
https://github.com/pandas-dev/pandas/blob/v0.23.4/pandas/core/strings.py#L2382-L2391

I agree that parameter should be renamed, can I take this one?
@ArtyomKaltovich 
> I agree that parameter should be renamed, can I take this one?

Sorry for the late reply, no reason you shouldn't tackle it!

Resolving patch:
diff --git a/pandas/core/strings.py b/pandas/core/strings.py
--- a/pandas/core/strings.py
+++ b/pandas/core/strings.py
@@ -19,7 +19,7 @@
 from pandas.core.algorithms import take_1d
 import pandas.compat as compat
 from pandas.core.base import NoNewAttributesMixin
-from pandas.util._decorators import Appender
+from pandas.util._decorators import Appender, deprecate_kwarg
 import re
 import pandas._libs.lib as lib
 import pandas._libs.ops as libops
@@ -2410,8 +2410,11 @@ def rsplit(self, pat=None, n=-1, expand=False):
 
     Parameters
     ----------
-    pat : str, default whitespace
+    sep : str, default whitespace
         String to split on.
+    pat : str, default whitespace
+        .. deprecated:: 0.24.0
+           Use ``sep`` instead
     expand : bool, default True
         If True, return DataFrame/MultiIndex expanding dimensionality.
         If False, return Series/Index.
@@ -2485,8 +2488,9 @@ def rsplit(self, pat=None, n=-1, expand=False):
                   'empty strings',
         'also': 'rpartition : Split the string at the last occurrence of `sep`'
     })
-    def partition(self, pat=' ', expand=True):
-        f = lambda x: x.partition(pat)
+    @deprecate_kwarg(old_arg_name='pat', new_arg_name='sep')
+    def partition(self, sep=' ', expand=True):
+        f = lambda x: x.partition(sep)
         result = _na_map(f, self._parent)
         return self._wrap_result(result, expand=expand)
 
@@ -2496,8 +2500,9 @@ def partition(self, pat=' ', expand=True):
                   'string itself',
         'also': 'partition : Split the string at the first occurrence of `sep`'
     })
-    def rpartition(self, pat=' ', expand=True):
-        f = lambda x: x.rpartition(pat)
+    @deprecate_kwarg(old_arg_name='pat', new_arg_name='sep')
+    def rpartition(self, sep=' ', expand=True):
+        f = lambda x: x.rpartition(sep)
         result = _na_map(f, self._parent)
         return self._wrap_result(result, expand=expand)
 


Test patch:
diff --git a/pandas/tests/test_strings.py b/pandas/tests/test_strings.py
--- a/pandas/tests/test_strings.py
+++ b/pandas/tests/test_strings.py
@@ -2586,6 +2586,24 @@ def test_partition_with_name(self):
         assert res.nlevels == 1
         tm.assert_index_equal(res, exp)
 
+    def test_partition_deprecation(self):
+        # GH 22676; depr kwarg "pat" in favor of "sep"
+        values = Series(['a_b_c', 'c_d_e', NA, 'f_g_h'])
+
+        # str.partition
+        # using sep -> no warning
+        expected = values.str.partition(sep='_')
+        with tm.assert_produces_warning(FutureWarning):
+            result = values.str.partition(pat='_')
+            tm.assert_frame_equal(result, expected)
+
+        # str.rpartition
+        # using sep -> no warning
+        expected = values.str.rpartition(sep='_')
+        with tm.assert_produces_warning(FutureWarning):
+            result = values.str.rpartition(pat='_')
+            tm.assert_frame_equal(result, expected)
+
     def test_pipe_failures(self):
         # #2119
         s = Series(['A|B|C'])