From 89259dbf74a9fd2e6f9f0879aeb116865a015e09 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 19 Mar 2021 15:42:09 -0400 Subject: [PATCH 01/68] if/else changes test --- pandas/core/series.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index e1a6c6884e003..247aed47a2ffc 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4737,8 +4737,8 @@ def between(self, left, right, inclusive=True) -> Series: dtype: bool """ if inclusive: - lmask = self >= left - rmask = self <= right + lmask = self > left + rmask = self < right else: lmask = self > left rmask = self < right From eda20a1f16da32e0cb95747e877c52bad8722845 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Sun, 21 Mar 2021 17:41:09 -0400 Subject: [PATCH 02/68] Series.between changes to inclusive boundaries --- pandas/core/series.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 247aed47a2ffc..3257cd7ab161e 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4670,7 +4670,7 @@ def isin(self, values) -> Series: self, method="isin" ) - def between(self, left, right, inclusive=True) -> Series: + def between(self, left, right, inclusive="True") -> Series: """ Return boolean Series equivalent to left <= series <= right. @@ -4736,12 +4736,21 @@ def between(self, left, right, inclusive=True) -> Series: 3 False dtype: bool """ - if inclusive: - lmask = self > left + + if inclusive == "True" or inclusive == "both": + lmask = self >= left + rmask = self <= right + elif inclusive == "left": + lmask = self >= left rmask = self < right - else: + elif inclusive == "right": + lmask = self > left + rmask = self <= right + elif inclusive == "False" or inclusive == "neither": lmask = self > left rmask = self < right + else: + print("Invalid inclusive input: string input of 'True', 'False' 'left', 'right', 'neither', or 'both' should be submitted") return lmask & rmask From 7af55a72c76b0c2db4a375e2fa8a0ac87556bc77 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 23 Mar 2021 20:41:58 -0400 Subject: [PATCH 03/68] changes to date_range parameters --- pandas/core/arrays/datetimelike.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 633a20d6bed37..21a1a7d9ebf5f 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1830,13 +1830,16 @@ def validate_endpoints(closed): left_closed = False right_closed = False - if closed is None: + if closed is None or closed == "True": left_closed = True right_closed = True elif closed == "left": left_closed = True elif closed == "right": right_closed = True + elif closed == "both" or closed == "False": + left_closed = False + right_closed = False else: raise ValueError("Closed has to be either 'left', 'right' or None") From 85a33ccfd030a13cc2d3ce4e80d57c1ed179c8ed Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 23 Mar 2021 21:02:26 -0400 Subject: [PATCH 04/68] Changed series.between error handling to throw value error instead of simple print statement --- pandas/core/series.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 3257cd7ab161e..044f269020875 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4746,11 +4746,11 @@ def between(self, left, right, inclusive="True") -> Series: elif inclusive == "right": lmask = self > left rmask = self <= right - elif inclusive == "False" or inclusive == "neither": + elif inclusive == "False": lmask = self > left rmask = self < right else: - print("Invalid inclusive input: string input of 'True', 'False' 'left', 'right', 'neither', or 'both' should be submitted") + raise ValueError("Invalid inclusive input: string input of 'True', 'False' 'left', 'right', or 'both' should be submitted") return lmask & rmask From c87e2409a4823e687e59a71a0d0639219d1ed439 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Wed, 24 Mar 2021 14:23:25 -0400 Subject: [PATCH 05/68] changes to series.between documentation and error message --- pandas/core/series.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 044f269020875..2a327940e3a6e 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4684,7 +4684,8 @@ def between(self, left, right, inclusive="True") -> Series: Left boundary. right : scalar or list-like Right boundary. - inclusive : bool, default True + inclusive : str, default "True" + Include boundaries. Returns @@ -4750,7 +4751,7 @@ def between(self, left, right, inclusive="True") -> Series: lmask = self > left rmask = self < right else: - raise ValueError("Invalid inclusive input: string input of 'True', 'False' 'left', 'right', or 'both' should be submitted") + raise ValueError("String input of 'True', 'both' 'False' 'left', 'right', should be submitted") return lmask & rmask From 4ebfa59ab611978fc18bf15203811e851c729a04 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Wed, 24 Mar 2021 23:33:42 -0400 Subject: [PATCH 06/68] parameters as either booleans or strings --- pandas/core/arrays/datetimelike.py | 6 +++--- pandas/core/series.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 21a1a7d9ebf5f..500fb789f183d 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1830,18 +1830,18 @@ def validate_endpoints(closed): left_closed = False right_closed = False - if closed is None or closed == "True": + if closed is None or closed == True or closed == "neither": left_closed = True right_closed = True elif closed == "left": left_closed = True elif closed == "right": right_closed = True - elif closed == "both" or closed == "False": + elif closed == "both" or closed == False: left_closed = False right_closed = False else: - raise ValueError("Closed has to be either 'left', 'right' or None") + raise ValueError("Closed has to be either 'left', 'right', 'neither', 'both' or None, or a boolean value") return left_closed, right_closed diff --git a/pandas/core/series.py b/pandas/core/series.py index 2a327940e3a6e..b5c18a52287e4 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4670,7 +4670,7 @@ def isin(self, values) -> Series: self, method="isin" ) - def between(self, left, right, inclusive="True") -> Series: + def between(self, left, right, inclusive=True) -> Series: """ Return boolean Series equivalent to left <= series <= right. @@ -4738,7 +4738,7 @@ def between(self, left, right, inclusive="True") -> Series: dtype: bool """ - if inclusive == "True" or inclusive == "both": + if inclusive == True or inclusive == "both": lmask = self >= left rmask = self <= right elif inclusive == "left": @@ -4747,11 +4747,11 @@ def between(self, left, right, inclusive="True") -> Series: elif inclusive == "right": lmask = self > left rmask = self <= right - elif inclusive == "False": + elif inclusive == False or inclusive == "neither": lmask = self > left rmask = self < right else: - raise ValueError("String input of 'True', 'both' 'False' 'left', 'right', should be submitted") + raise ValueError("Input should be boolean or string of 'both', 'left', 'right', or 'neither'") return lmask & rmask From ad3670e48478fa7db447616c99bb49b05acee22a Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 00:13:16 -0400 Subject: [PATCH 07/68] full range of options in documentation --- Pipfile | 12 +++++ Pipfile.lock | 84 ++++++++++++++++++++++++++++++ pandas/core/arrays/datetimelike.py | 2 +- pandas/core/series.py | 2 +- 4 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 Pipfile create mode 100644 Pipfile.lock diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000000000..11c3029ac801e --- /dev/null +++ b/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] +pytest = "*" + +[requires] +python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000000000..709cae0b2e217 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,84 @@ +{ + "_meta": { + "hash": { + "sha256": "44ccf4c66d663506b934edaa5a4873daba29d125557d68c7840956adb918c913" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.8" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": {}, + "develop": { + "attrs": { + "hashes": [ + "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6", + "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==20.3.0" + }, + "iniconfig": { + "hashes": [ + "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", + "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" + ], + "version": "==1.1.1" + }, + "packaging": { + "hashes": [ + "sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a230374cc1fd776feae5", + "sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21f051443c20947a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==20.9" + }, + "pluggy": { + "hashes": [ + "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0", + "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.13.1" + }, + "py": { + "hashes": [ + "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3", + "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.10.0" + }, + "pyparsing": { + "hashes": [ + "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", + "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.4.7" + }, + "pytest": { + "hashes": [ + "sha256:9d1edf9e7d0b84d72ea3dbcdfd22b35fb543a5e8f2a60092dd578936bf63d7f9", + "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839" + ], + "index": "pypi", + "version": "==6.2.2" + }, + "toml": { + "hashes": [ + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.10.2" + } + } +} diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 500fb789f183d..9c832b95e3fbb 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1816,7 +1816,7 @@ def validate_endpoints(closed): Parameters ---------- - closed : {None, "left", "right"} + closed : {None, True, False, "neither", "left", "right", "both"} Returns ------- diff --git a/pandas/core/series.py b/pandas/core/series.py index b5c18a52287e4..31627c26540db 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4684,7 +4684,7 @@ def between(self, left, right, inclusive=True) -> Series: Left boundary. right : scalar or list-like Right boundary. - inclusive : str, default "True" + inclusive : boolean or str, default "True" Include boundaries. From 1dc37b15072490e9e4d092e2a34bcd2d7ffd979d Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 00:14:36 -0400 Subject: [PATCH 08/68] Order of parameters in documentation --- pandas/core/arrays/datetimelike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 9c832b95e3fbb..30d54755a66cc 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1816,7 +1816,7 @@ def validate_endpoints(closed): Parameters ---------- - closed : {None, True, False, "neither", "left", "right", "both"} + closed : {None, False, True, "neither", "left", "right", "both"} Returns ------- From d3f6a569c56cb3a0bc82800fd354a5246bfff1b2 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 01:48:03 -0400 Subject: [PATCH 09/68] changes to if statement format --- pandas/core/arrays/datetimelike.py | 4 ++-- pandas/core/series.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 30d54755a66cc..bb57c78c0af8b 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1830,14 +1830,14 @@ def validate_endpoints(closed): left_closed = False right_closed = False - if closed is None or closed == True or closed == "neither": + if closed is None or closed is True or closed == "neither": left_closed = True right_closed = True elif closed == "left": left_closed = True elif closed == "right": right_closed = True - elif closed == "both" or closed == False: + elif closed == "both" or closed is False: left_closed = False right_closed = False else: diff --git a/pandas/core/series.py b/pandas/core/series.py index 31627c26540db..3e66d6e3b56e8 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4738,7 +4738,7 @@ def between(self, left, right, inclusive=True) -> Series: dtype: bool """ - if inclusive == True or inclusive == "both": + if inclusive is True or inclusive == "both": lmask = self >= left rmask = self <= right elif inclusive == "left": @@ -4747,7 +4747,7 @@ def between(self, left, right, inclusive=True) -> Series: elif inclusive == "right": lmask = self > left rmask = self <= right - elif inclusive == False or inclusive == "neither": + elif inclusive is False or inclusive == "neither": lmask = self > left rmask = self < right else: From 70fb07666700cab12207c8c2da8bcf48362d6afe Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 02:12:13 -0400 Subject: [PATCH 10/68] Corrections to line length linting errors in ValueError messages --- pandas/core/arrays/datetimelike.py | 6 ++++-- pandas/core/series.py | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index bb57c78c0af8b..7d2a0ff7d268b 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1841,8 +1841,10 @@ def validate_endpoints(closed): left_closed = False right_closed = False else: - raise ValueError("Closed has to be either 'left', 'right', 'neither', 'both' or None, or a boolean value") - + raise ValueError( + "Closed has to be either 'left', 'right'," + "'neither', 'both' or None, or a boolean value" + ) return left_closed, right_closed diff --git a/pandas/core/series.py b/pandas/core/series.py index 3e66d6e3b56e8..7b447f7190ce3 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4751,7 +4751,10 @@ def between(self, left, right, inclusive=True) -> Series: lmask = self > left rmask = self < right else: - raise ValueError("Input should be boolean or string of 'both', 'left', 'right', or 'neither'") + raise ValueError( + "Input should be boolean or string of 'both'," + " 'left', 'right', or 'neither'" + ) return lmask & rmask From 3382a7ec17ad40a177f3cc9cf3ad56d03d145ccb Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 02:22:12 -0400 Subject: [PATCH 11/68] Format of ValueError statements --- pandas/core/arrays/datetimelike.py | 4 ++-- pandas/core/series.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 7d2a0ff7d268b..d20431eae6970 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1842,8 +1842,8 @@ def validate_endpoints(closed): right_closed = False else: raise ValueError( - "Closed has to be either 'left', 'right'," - "'neither', 'both' or None, or a boolean value" + "Closed has to be either 'left', 'right', 'neither', 'both' or" + "None, or a boolean value" ) return left_closed, right_closed diff --git a/pandas/core/series.py b/pandas/core/series.py index 7b447f7190ce3..1fd0861d1f74b 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4752,8 +4752,8 @@ def between(self, left, right, inclusive=True) -> Series: rmask = self < right else: raise ValueError( - "Input should be boolean or string of 'both'," - " 'left', 'right', or 'neither'" + "Input should be boolean or string of 'both','left', 'right'," + " or 'neither'" ) return lmask & rmask From f693b904a75d8bd19ec9aff3ca1a69f3dc447810 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 02:29:36 -0400 Subject: [PATCH 12/68] Format of spaces in ValueError statements --- pandas/core/arrays/datetimelike.py | 2 +- pandas/core/series.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index d20431eae6970..40e034de1e03d 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1842,7 +1842,7 @@ def validate_endpoints(closed): right_closed = False else: raise ValueError( - "Closed has to be either 'left', 'right', 'neither', 'both' or" + "Closed has to be either 'left', 'right', 'neither', 'both' or " "None, or a boolean value" ) return left_closed, right_closed diff --git a/pandas/core/series.py b/pandas/core/series.py index 1fd0861d1f74b..9c2c70561b043 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4752,8 +4752,8 @@ def between(self, left, right, inclusive=True) -> Series: rmask = self < right else: raise ValueError( - "Input should be boolean or string of 'both','left', 'right'," - " or 'neither'" + "Input should be boolean or string of 'both','left', 'right', " + "or 'neither'" ) return lmask & rmask From 895b20af61babc0c401e1c30842714e99e5fae69 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Thu, 25 Mar 2021 10:14:48 -0400 Subject: [PATCH 13/68] Delete Pipfile --- Pipfile | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Pipfile diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 11c3029ac801e..0000000000000 --- a/Pipfile +++ /dev/null @@ -1,12 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] - -[dev-packages] -pytest = "*" - -[requires] -python_version = "3.8" From d35263c0c15e607191a48770121b21e0938a0ab1 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Thu, 25 Mar 2021 10:14:58 -0400 Subject: [PATCH 14/68] Delete Pipfile.lock --- Pipfile.lock | 84 ---------------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 Pipfile.lock diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 709cae0b2e217..0000000000000 --- a/Pipfile.lock +++ /dev/null @@ -1,84 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "44ccf4c66d663506b934edaa5a4873daba29d125557d68c7840956adb918c913" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.8" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": {}, - "develop": { - "attrs": { - "hashes": [ - "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6", - "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==20.3.0" - }, - "iniconfig": { - "hashes": [ - "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", - "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" - ], - "version": "==1.1.1" - }, - "packaging": { - "hashes": [ - "sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a230374cc1fd776feae5", - "sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21f051443c20947a" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==20.9" - }, - "pluggy": { - "hashes": [ - "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0", - "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==0.13.1" - }, - "py": { - "hashes": [ - "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3", - "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.10.0" - }, - "pyparsing": { - "hashes": [ - "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", - "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" - ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==2.4.7" - }, - "pytest": { - "hashes": [ - "sha256:9d1edf9e7d0b84d72ea3dbcdfd22b35fb543a5e8f2a60092dd578936bf63d7f9", - "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839" - ], - "index": "pypi", - "version": "==6.2.2" - }, - "toml": { - "hashes": [ - "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", - "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" - ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==0.10.2" - } - } -} From 13648d20096c5dfe3766552433aebeef058f6e4e Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 21:37:38 -0400 Subject: [PATCH 15/68] parameters for standard values and backwards compatibility --- Pipfile | 12 ----- Pipfile.lock | 84 ------------------------------ pandas/core/arrays/datetimelike.py | 4 +- pandas/core/series.py | 6 +-- 4 files changed, 5 insertions(+), 101 deletions(-) delete mode 100644 Pipfile delete mode 100644 Pipfile.lock diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 11c3029ac801e..0000000000000 --- a/Pipfile +++ /dev/null @@ -1,12 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] - -[dev-packages] -pytest = "*" - -[requires] -python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 709cae0b2e217..0000000000000 --- a/Pipfile.lock +++ /dev/null @@ -1,84 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "44ccf4c66d663506b934edaa5a4873daba29d125557d68c7840956adb918c913" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.8" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": {}, - "develop": { - "attrs": { - "hashes": [ - "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6", - "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==20.3.0" - }, - "iniconfig": { - "hashes": [ - "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", - "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" - ], - "version": "==1.1.1" - }, - "packaging": { - "hashes": [ - "sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a230374cc1fd776feae5", - "sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21f051443c20947a" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==20.9" - }, - "pluggy": { - "hashes": [ - "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0", - "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==0.13.1" - }, - "py": { - "hashes": [ - "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3", - "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.10.0" - }, - "pyparsing": { - "hashes": [ - "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", - "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" - ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==2.4.7" - }, - "pytest": { - "hashes": [ - "sha256:9d1edf9e7d0b84d72ea3dbcdfd22b35fb543a5e8f2a60092dd578936bf63d7f9", - "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839" - ], - "index": "pypi", - "version": "==6.2.2" - }, - "toml": { - "hashes": [ - "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", - "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" - ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==0.10.2" - } - } -} diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 40e034de1e03d..5d81f42b2811d 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1816,7 +1816,7 @@ def validate_endpoints(closed): Parameters ---------- - closed : {None, False, True, "neither", "left", "right", "both"} + closed : {"neither", "left", "right", "both"} Returns ------- @@ -1830,7 +1830,7 @@ def validate_endpoints(closed): left_closed = False right_closed = False - if closed is None or closed is True or closed == "neither": + if closed == "neither" or closed is True or closed is None: left_closed = True right_closed = True elif closed == "left": diff --git a/pandas/core/series.py b/pandas/core/series.py index 9c2c70561b043..57f8eb2a09f60 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4684,7 +4684,7 @@ def between(self, left, right, inclusive=True) -> Series: Left boundary. right : scalar or list-like Right boundary. - inclusive : boolean or str, default "True" + inclusive : str, default "both" Include boundaries. @@ -4738,7 +4738,7 @@ def between(self, left, right, inclusive=True) -> Series: dtype: bool """ - if inclusive is True or inclusive == "both": + if inclusive == "both" or inclusive is True: lmask = self >= left rmask = self <= right elif inclusive == "left": @@ -4747,7 +4747,7 @@ def between(self, left, right, inclusive=True) -> Series: elif inclusive == "right": lmask = self > left rmask = self <= right - elif inclusive is False or inclusive == "neither": + elif inclusive == "neither" or inclusive is False: lmask = self > left rmask = self < right else: From b9249269c2d331f6a16d01025f744fe06fb4845b Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 21:40:16 -0400 Subject: [PATCH 16/68] ENH: parameters for standard values and backwards compatibility --- pandas/core/arrays/datetimelike.py | 2 +- pandas/core/series.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 5d81f42b2811d..9e71fed93f5e2 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1812,7 +1812,7 @@ def validate_periods(periods): def validate_endpoints(closed): """ - Check that the `closed` argument is among [None, "left", "right"] + Check that the `closed` argument is among [None, "neither", "left", "right"] Parameters ---------- diff --git a/pandas/core/series.py b/pandas/core/series.py index 57f8eb2a09f60..fe2d81441abd5 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4676,7 +4676,7 @@ def between(self, left, right, inclusive=True) -> Series: This function returns a boolean vector containing `True` wherever the corresponding Series element is between the boundary values `left` and - `right`. NA values are treated as `False`. + `right`. ValueError is raised for NA values. Parameters ---------- @@ -4684,7 +4684,7 @@ def between(self, left, right, inclusive=True) -> Series: Left boundary. right : scalar or list-like Right boundary. - inclusive : str, default "both" + inclusive : str or boolean, default "both" Include boundaries. From 42e4209fe6806f1cd4b210f66bbaa4616b05ff21 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 21:46:41 -0400 Subject: [PATCH 17/68] ENH: corrections about parameter arguments in method docstrings --- pandas/core/arrays/datetimelike.py | 3 ++- pandas/core/series.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 9e71fed93f5e2..087d729a85c3e 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1812,7 +1812,8 @@ def validate_periods(periods): def validate_endpoints(closed): """ - Check that the `closed` argument is among [None, "neither", "left", "right"] + Check that the `closed` argument is among ["neither", "left", "right", \ + None, or backwards compatibility argument of True, False, or None] Parameters ---------- diff --git a/pandas/core/series.py b/pandas/core/series.py index fe2d81441abd5..dcb9a26a76426 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4676,7 +4676,7 @@ def between(self, left, right, inclusive=True) -> Series: This function returns a boolean vector containing `True` wherever the corresponding Series element is between the boundary values `left` and - `right`. ValueError is raised for NA values. + `right`. NA values are treated as `False`. Parameters ---------- @@ -4684,7 +4684,7 @@ def between(self, left, right, inclusive=True) -> Series: Left boundary. right : scalar or list-like Right boundary. - inclusive : str or boolean, default "both" + inclusive : str or boolean, default True Include boundaries. From 1570eb667684869adb82d00442a5d74347818a5e Mon Sep 17 00:00:00 2001 From: declanjcasey Date: Thu, 25 Mar 2021 22:49:17 -0400 Subject: [PATCH 18/68] add passing test case for test_between.py --- Dockerfile | 2 +- pandas/tests/series/methods/test_between.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index de1c564921de9..aad8e3c38fdc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM quay.io/condaforge/miniforge3 # if you forked pandas, you can pass in your own GitHub username to use your fork # i.e. gh_username=myname -ARG gh_username=pandas-dev +ARG gh_username=hewittk ARG pandas_home="/home/pandas" # Avoid warnings by switching to noninteractive diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index 381c733619c6b..b7a0347cc818a 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -1,4 +1,5 @@ import numpy as np +import pytest from pandas import ( Series, @@ -9,6 +10,8 @@ import pandas._testing as tm + + class TestBetween: # TODO: redundant with test_between_datetime_values? @@ -38,3 +41,9 @@ def test_between_period_values(self): result = ser.between(left, right) expected = (ser >= left) & (ser <= right) tm.assert_series_equal(result, expected) + + def test_between_inclusive_is_boolean_string(self): + with pytest.raises(ValueError): + ser = Series(period_range("2000-01-01", periods=10, freq="D")) + left, right = ser[[2, 7]] + ser.between(left, right, 8) From b5245237ef6bee7aba7a91d42678c4e97cc850f4 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 22:50:14 -0400 Subject: [PATCH 19/68] ENH: corrections to placements of both/neither in datetime if/else statement --- pandas/core/arrays/datetimelike.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 087d729a85c3e..e81782f3c01f9 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1831,14 +1831,14 @@ def validate_endpoints(closed): left_closed = False right_closed = False - if closed == "neither" or closed is True or closed is None: + if closed == "both" or closed is True or closed is None: left_closed = True right_closed = True elif closed == "left": left_closed = True elif closed == "right": right_closed = True - elif closed == "both" or closed is False: + elif closed == "neither" or closed is False: left_closed = False right_closed = False else: From 991b2385cdde27f2e3fd9f8efaeffefe99d7a5c5 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 23:35:23 -0400 Subject: [PATCH 20/68] ENH: reformatting of series ValueError message --- pandas/core/series.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index dcb9a26a76426..580efdb51fd20 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4752,8 +4752,8 @@ def between(self, left, right, inclusive=True) -> Series: rmask = self < right else: raise ValueError( - "Input should be boolean or string of 'both','left', 'right', " - "or 'neither'" + "Inclusive has to be either string of 'both','left', 'right', " + "or 'neither', or a boolean value" ) return lmask & rmask From 6009878e8a0b9f5498dd5fb76e4a7fa2db86394e Mon Sep 17 00:00:00 2001 From: declanjcasey Date: Thu, 25 Mar 2021 23:35:37 -0400 Subject: [PATCH 21/68] add asset statemente to new method test_between_inclusive_is_boolean_strin --- pandas/tests/series/methods/test_between.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index b7a0347cc818a..dcf5353cf2c76 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -46,4 +46,4 @@ def test_between_inclusive_is_boolean_string(self): with pytest.raises(ValueError): ser = Series(period_range("2000-01-01", periods=10, freq="D")) left, right = ser[[2, 7]] - ser.between(left, right, 8) + assert ser.between(left, right, 8) From 944c28af9478198a2ef8356239b47e9d510f2ef5 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Thu, 25 Mar 2021 23:48:53 -0400 Subject: [PATCH 22/68] ENH: changed default parameter of inclusive to string --- pandas/core/series.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 580efdb51fd20..e75dd4e3ca1d6 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4670,7 +4670,7 @@ def isin(self, values) -> Series: self, method="isin" ) - def between(self, left, right, inclusive=True) -> Series: + def between(self, left, right, inclusive="both") -> Series: """ Return boolean Series equivalent to left <= series <= right. @@ -4684,7 +4684,7 @@ def between(self, left, right, inclusive=True) -> Series: Left boundary. right : scalar or list-like Right boundary. - inclusive : str or boolean, default True + inclusive : str or boolean, default "both" Include boundaries. From 9dced1060fa51139f394a9b47b83f07e996f562f Mon Sep 17 00:00:00 2001 From: declanjcasey Date: Thu, 25 Mar 2021 23:52:04 -0400 Subject: [PATCH 23/68] add macth variable for pytest.raises() --- pandas/tests/series/methods/test_between.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index dcf5353cf2c76..3af491fbb7056 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -43,7 +43,8 @@ def test_between_period_values(self): tm.assert_series_equal(result, expected) def test_between_inclusive_is_boolean_string(self): - with pytest.raises(ValueError): + msg = "Inclusive has to be either string of 'both','left', 'right', or 'neither', or a boolean value" + with pytest.raises(ValueError, match=msg): ser = Series(period_range("2000-01-01", periods=10, freq="D")) left, right = ser[[2, 7]] assert ser.between(left, right, 8) From 8a7915579179d7bdd2929af391946f0d79663de1 Mon Sep 17 00:00:00 2001 From: declanjcasey Date: Fri, 26 Mar 2021 00:07:39 -0400 Subject: [PATCH 24/68] edit variable declration in test_between_inclusive_is_boolean_string() --- pandas/tests/series/methods/test_between.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index 3af491fbb7056..14f3a34198685 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -43,8 +43,10 @@ def test_between_period_values(self): tm.assert_series_equal(result, expected) def test_between_inclusive_is_boolean_string(self): - msg = "Inclusive has to be either string of 'both','left', 'right', or 'neither', or a boolean value" - with pytest.raises(ValueError, match=msg): + msg_1 = "Inclusive has to be either string of 'both','left', " + msg_2 = "'right', or 'neither', or a boolean value" + msg = msg_1 + msg_2 + with pytest.raises(ValueError, match=msg): ser = Series(period_range("2000-01-01", periods=10, freq="D")) left, right = ser[[2, 7]] assert ser.between(left, right, 8) From d9a4130984183b5f45ffbad2f15074aa5088fdd4 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 26 Mar 2021 00:23:14 -0400 Subject: [PATCH 25/68] ENH: Correction to closed argument documentation formatting --- pandas/core/arrays/datetimelike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index e81782f3c01f9..3491ee0c6deed 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1812,7 +1812,7 @@ def validate_periods(periods): def validate_endpoints(closed): """ - Check that the `closed` argument is among ["neither", "left", "right", \ + Check that the `closed` argument is among ["neither", "left", "right", None, or backwards compatibility argument of True, False, or None] Parameters From 062c58b869b15043ef3854bd93f326af7cc25510 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 26 Mar 2021 00:47:57 -0400 Subject: [PATCH 26/68] ENH: whatsnew message about issue enhancements --- doc/source/whatsnew/v1.3.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index ecb9830024900..12763a54ffa1f 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -139,6 +139,7 @@ Other enhancements - :meth:`pandas.read_stata` and :class:`StataReader` support reading data from compressed files. - Add support for parsing ``ISO 8601``-like timestamps with negative signs to :meth:`pandas.Timedelta` (:issue:`37172`) - Add support for unary operators in :class:`FloatingArray` (:issue:`38749`) +- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` so that ["left", "right", "neither", both"] are standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- From bed87e307c5ac3049270fe3f545ce6ac98596a21 Mon Sep 17 00:00:00 2001 From: declanjcasey Date: Fri, 26 Mar 2021 00:53:12 -0400 Subject: [PATCH 27/68] reformat for black --- pandas/tests/series/methods/test_between.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index 14f3a34198685..6eba0dd954803 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -10,8 +10,6 @@ import pandas._testing as tm - - class TestBetween: # TODO: redundant with test_between_datetime_values? From 86a8961d5effb26ee5cf0876050bcc682a95d26e Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 26 Mar 2021 00:57:41 -0400 Subject: [PATCH 28/68] ENH: whatsnew message about issue enhancements --- doc/source/whatsnew/v1.3.0.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 12763a54ffa1f..5be6aa3bf8815 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -139,6 +139,9 @@ Other enhancements - :meth:`pandas.read_stata` and :class:`StataReader` support reading data from compressed files. - Add support for parsing ``ISO 8601``-like timestamps with negative signs to :meth:`pandas.Timedelta` (:issue:`37172`) - Add support for unary operators in :class:`FloatingArray` (:issue:`38749`) +- :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`) +- :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`) +- :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`) - Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` so that ["left", "right", "neither", both"] are standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- From 3f04091a6100da16a29a30f087b0d8b83195a5a8 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 26 Mar 2021 01:00:24 -0400 Subject: [PATCH 29/68] Improved formatting of whatsnew message --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 5be6aa3bf8815..503a2b839e2e2 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -142,7 +142,7 @@ Other enhancements - :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`) - :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`) - :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`) -- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` so that ["left", "right", "neither", both"] are standard argument values for both methods (:issue:`40628`) +- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` to have `["left", "right", "neither", "both"]` as standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- From 163a08cb7ebf4b5f628b3af818a5ed1507746387 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 26 Mar 2021 01:02:26 -0400 Subject: [PATCH 30/68] Code block in whatsnew message --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 503a2b839e2e2..f185d02d2ef6f 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -142,7 +142,7 @@ Other enhancements - :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`) - :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`) - :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`) -- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` to have `["left", "right", "neither", "both"]` as standard argument values for both methods (:issue:`40628`) +- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` to have ``["left", "right", "neither", "both"]``` as standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- From 82407632d2f784b978e0f878472a24ee51cbfc70 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 26 Mar 2021 01:16:41 -0400 Subject: [PATCH 31/68] Formatting on whatsnew issue --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index f185d02d2ef6f..97eb18f73e53e 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -142,7 +142,7 @@ Other enhancements - :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`) - :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`) - :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`) -- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` to have ``["left", "right", "neither", "both"]``` as standard argument values for both methods (:issue:`40628`) +- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` to have ``["left", "right", "neither", "both"]` as standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- From d62bcc3b438e54d7918f306ece32ef3982a136f6 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 26 Mar 2021 13:53:15 -0400 Subject: [PATCH 32/68] Documentation representing standard and backwards compatibility boundary parameter values --- doc/source/whatsnew/v1.3.0.rst | 2 +- pandas/core/arrays/datetimelike.py | 2 ++ pandas/core/series.py | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 97eb18f73e53e..874f266609ac8 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -142,7 +142,7 @@ Other enhancements - :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`) - :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`) - :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`) -- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` to have ``["left", "right", "neither", "both"]` as standard argument values for both methods (:issue:`40628`) +- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` to have ``["left", "right", "neither", "both"]`` as standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 3491ee0c6deed..370fc220ca752 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1818,6 +1818,8 @@ def validate_endpoints(closed): Parameters ---------- closed : {"neither", "left", "right", "both"} + Whether to set each bound as closed or open. For backwards compatibility this can also + be set to ``True`` ("both"), False ("neither") or None (..) Returns ------- diff --git a/pandas/core/series.py b/pandas/core/series.py index e75dd4e3ca1d6..6c256b02ba744 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4684,7 +4684,10 @@ def between(self, left, right, inclusive="both") -> Series: Left boundary. right : scalar or list-like Right boundary. - inclusive : str or boolean, default "both" + inclusive : {"both", "neither", "left", "right"} + Whether to set each bound as closed or open. For backwards + compatibility this can also be set to ``True`` ("both") or + False ("neither") Include boundaries. From 9761c21160a5286e71369d268a60427b9cc7b74d Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Fri, 26 Mar 2021 14:00:07 -0400 Subject: [PATCH 33/68] Reformatting of relevant addition and removal of unnecessary additions --- doc/source/whatsnew/v1.3.0.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 43dbc4e6ffa03..5057e44fbc47b 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -142,10 +142,7 @@ Other enhancements - :meth:`pandas.read_stata` and :class:`StataReader` support reading data from compressed files. - Add support for parsing ``ISO 8601``-like timestamps with negative signs to :meth:`pandas.Timedelta` (:issue:`37172`) - Add support for unary operators in :class:`FloatingArray` (:issue:`38749`) -- :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`) -- :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`) -- :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`) -- Add consistency of arguments in `series.between` and `datetimelike.validate_endpoints` to have ``["left", "right", "neither", "both"]`` as standard argument values for both methods (:issue:`40628`) +- Add consistency of arguments in :meth:`Series.between` and :meth:`.datetimelike.validate_endpoints` to have ``{"left", "right", "neither", "both"}`` as standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- From 2f35f81e91e5f90b33a14c17a5af5e7a7d4a9827 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:05:35 -0400 Subject: [PATCH 34/68] Update pandas/core/arrays/datetimelike.py Co-authored-by: attack68 <24256554+attack68@users.noreply.github.com> --- pandas/core/arrays/datetimelike.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index b2848bf5131c7..49d21bcc52670 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1842,8 +1842,8 @@ def validate_periods(periods): def validate_endpoints(closed): """ - Check that the `closed` argument is among ["neither", "left", "right", - None, or backwards compatibility argument of True, False, or None] + Check that the ``closed`` argument is a valid string input, or, + for backwards compatibility, one of ``{True, False, or None}``. Parameters ---------- From 10d5594088cedfc56cfd9c182551efe5a1f9ff90 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Mon, 3 May 2021 14:32:10 -0400 Subject: [PATCH 35/68] Revert validate_endpoints --- pandas/core/arrays/datetimelike.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 49d21bcc52670..b4551e7f9d24c 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1842,20 +1842,14 @@ def validate_periods(periods): def validate_endpoints(closed): """ - Check that the ``closed`` argument is a valid string input, or, - for backwards compatibility, one of ``{True, False, or None}``. - + Check that the `closed` argument is among [None, "left", "right"] Parameters ---------- - closed : {"neither", "left", "right", "both"} - Whether to set each bound as closed or open. For backwards compatibility this can also - be set to ``True`` ("both"), False ("neither") or None (..) - + closed : {None, "left", "right"} Returns ------- left_closed : bool right_closed : bool - Raises ------ ValueError : if argument is not among valid values @@ -1863,21 +1857,16 @@ def validate_endpoints(closed): left_closed = False right_closed = False - if closed == "both" or closed is True or closed is None: + if closed is None: left_closed = True right_closed = True elif closed == "left": left_closed = True elif closed == "right": right_closed = True - elif closed == "neither" or closed is False: - left_closed = False - right_closed = False else: - raise ValueError( - "Closed has to be either 'left', 'right', 'neither', 'both' or " - "None, or a boolean value" - ) + raise ValueError("Closed has to be either 'left', 'right' or None") + return left_closed, right_closed From 1c7a17d6619ab3c7edaf7741f6b652a0f5b8e6df Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 4 May 2021 13:00:29 -0400 Subject: [PATCH 36/68] Revert whatsnew to include all previous entries on branch --- doc/source/whatsnew/v1.3.0.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 5057e44fbc47b..900d88bff822e 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -142,6 +142,9 @@ Other enhancements - :meth:`pandas.read_stata` and :class:`StataReader` support reading data from compressed files. - Add support for parsing ``ISO 8601``-like timestamps with negative signs to :meth:`pandas.Timedelta` (:issue:`37172`) - Add support for unary operators in :class:`FloatingArray` (:issue:`38749`) +- :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`) +- :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`) +- :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`) - Add consistency of arguments in :meth:`Series.between` and :meth:`.datetimelike.validate_endpoints` to have ``{"left", "right", "neither", "both"}`` as standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- From e03ed0dd850ba178d2ac795cf6c33eb0a3a4cede Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 4 May 2021 13:46:31 -0400 Subject: [PATCH 37/68] Move whatsnew entry to deprecation section --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 900d88bff822e..31c23bd052773 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -145,7 +145,6 @@ Other enhancements - :class:`RangeIndex` can now be constructed by passing a ``range`` object directly e.g. ``pd.RangeIndex(range(3))`` (:issue:`12067`) - :meth:`round` being enabled for the nullable integer and floating dtypes (:issue:`38844`) - :meth:`pandas.read_csv` and :meth:`pandas.read_json` expose the argument ``encoding_errors`` to control how encoding errors are handled (:issue:`39450`) -- Add consistency of arguments in :meth:`Series.between` and :meth:`.datetimelike.validate_endpoints` to have ``{"left", "right", "neither", "both"}`` as standard argument values for both methods (:issue:`40628`) .. --------------------------------------------------------------------------- @@ -427,6 +426,7 @@ Deprecations - Deprecated allowing partial failure in :meth:`Series.transform` and :meth:`DataFrame.transform` when ``func`` is list-like or dict-like and raises anything but ``TypeError``; ``func`` raising anything but a ``TypeError`` will raise in a future version (:issue:`40211`) - Deprecated support for ``np.ma.mrecords.MaskedRecords`` in the :class:`DataFrame` constructor, pass ``{name: data[name] for name in data.dtype.names}`` instead (:issue:`40363`) - Deprecated the use of ``**kwargs`` in :class:`.ExcelWriter`; use the keyword argument ``engine_kwargs`` instead (:issue:`40430`) +- Deprecated boolean arguments of ``inclusive`` in :meth:`Series.between` to have ``{"left", "right", "neither", "both"}`` as standard argument values (:issue:`40628`) .. --------------------------------------------------------------------------- From 1ae01cb8247a50b4ad9ccabfe655a292d682af5b Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 4 May 2021 14:01:23 -0400 Subject: [PATCH 38/68] Reorganize inclusive arg documentation and add version changed --- pandas/core/series.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 0eb3e309b210b..fdd453e349bac 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4747,11 +4747,12 @@ def between(self, left, right, inclusive="both") -> Series: right : scalar or list-like Right boundary. inclusive : {"both", "neither", "left", "right"} - Whether to set each bound as closed or open. For backwards - compatibility this can also be set to ``True`` ("both") or - False ("neither") + Include boundaries. Whether to set each bound as closed or open. + For backwards compatibility this can also be set to ``True`` + ("both") or false ("neither") + + .. versionchanged:: 1.3.0 - Include boundaries. Returns ------- From 171e212c69348d69fcd7caa23ba3700497aedbc4 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 4 May 2021 15:40:19 -0400 Subject: [PATCH 39/68] Test cases for all provided arguments --- pandas/tests/series/methods/test_between.py | 34 ++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index 6eba0dd954803..ad7219e958cda 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -1,5 +1,4 @@ import numpy as np -import pytest from pandas import ( Series, @@ -41,10 +40,29 @@ def test_between_period_values(self): tm.assert_series_equal(result, expected) def test_between_inclusive_is_boolean_string(self): - msg_1 = "Inclusive has to be either string of 'both','left', " - msg_2 = "'right', or 'neither', or a boolean value" - msg = msg_1 + msg_2 - with pytest.raises(ValueError, match=msg): - ser = Series(period_range("2000-01-01", periods=10, freq="D")) - left, right = ser[[2, 7]] - assert ser.between(left, right, 8) + series = Series(date_range("1/1/2000", periods=10)) + left, right = series[[2, 7]] + + result = series.between(left, right, inclusive="both") + expected = (series >= left) & (series <= right) + tm.assert_series_equal(result, expected) + + result = series.between(left, right, inclusive="left") + expected = (series >= left) & (series < right) + tm.assert_series_equal(result, expected) + + result = series.between(left, right, inclusive="right") + expected = (series > left) & (series <= right) + tm.assert_series_equal(result, expected) + + result = series.between(left, right, inclusive="neither") + expected = (series > left) & (series < right) + tm.assert_series_equal(result, expected) + + result = series.between(left, right, inclusive=True) + expected = (series >= left) & (series <= right) + tm.assert_series_equal(result, expected) + + result = series.between(left, right, inclusive=False) + expected = (series > left) & (series < right) + tm.assert_series_equal(result, expected) From ef9350f374aa50e61a668a893079a5bacb11f42a Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 4 May 2021 15:49:14 -0400 Subject: [PATCH 40/68] ValueError test case --- pandas/tests/series/methods/test_between.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index ad7219e958cda..09fab7441a862 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -1,4 +1,5 @@ import numpy as np +import pytest from pandas import ( Series, @@ -66,3 +67,11 @@ def test_between_inclusive_is_boolean_string(self): result = series.between(left, right, inclusive=False) expected = (series > left) & (series < right) tm.assert_series_equal(result, expected) + + value_error_msg = """"Inclusive has to be either string of 'both', + 'left', 'right', or 'neither', or a boolean value""" + + with pytest.raises(ValueError, match=value_error_msg): + series = Series(date_range("1/1/2000", periods=10)) + left, right = series[[2, 7]] + series.between(left, right, inclusive="yes") From 873e6699e4b8fac33dd9eb19e46fab1fffa18a64 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 4 May 2021 15:49:57 -0400 Subject: [PATCH 41/68] Remove redundant line --- pandas/tests/series/methods/test_between.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index 09fab7441a862..b10355499edfe 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -73,5 +73,4 @@ def test_between_inclusive_is_boolean_string(self): with pytest.raises(ValueError, match=value_error_msg): series = Series(date_range("1/1/2000", periods=10)) - left, right = series[[2, 7]] series.between(left, right, inclusive="yes") From 810441353e63a70c378ff1c2afe8802d5efa36ad Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 4 May 2021 15:55:26 -0400 Subject: [PATCH 42/68] Add issue number to added test --- pandas/tests/series/methods/test_between.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index b10355499edfe..e7c5fd9388a49 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -40,6 +40,7 @@ def test_between_period_values(self): expected = (ser >= left) & (ser <= right) tm.assert_series_equal(result, expected) + # :issue:`40628` def test_between_inclusive_is_boolean_string(self): series = Series(date_range("1/1/2000", periods=10)) left, right = series[[2, 7]] From a9380c50715ced6ee368ced8cbff79e59b14d8e7 Mon Sep 17 00:00:00 2001 From: Kiley <> Date: Tue, 4 May 2021 15:56:56 -0400 Subject: [PATCH 43/68] Revert username in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index aad8e3c38fdc3..de1c564921de9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM quay.io/condaforge/miniforge3 # if you forked pandas, you can pass in your own GitHub username to use your fork # i.e. gh_username=myname -ARG gh_username=hewittk +ARG gh_username=pandas-dev ARG pandas_home="/home/pandas" # Avoid warnings by switching to noninteractive From 0c974ca7509c85864b177a657e88ec32125e9330 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Tue, 4 May 2021 16:07:44 -0400 Subject: [PATCH 44/68] Revert remaining changes to validate_endpoints --- pandas/core/arrays/datetimelike.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index b4551e7f9d24c..38f708ca0a967 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1843,13 +1843,16 @@ def validate_periods(periods): def validate_endpoints(closed): """ Check that the `closed` argument is among [None, "left", "right"] + Parameters ---------- closed : {None, "left", "right"} + Returns ------- left_closed : bool right_closed : bool + Raises ------ ValueError : if argument is not among valid values From 0da45097885934117f25693837a4af024248efc8 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Tue, 4 May 2021 16:13:03 -0400 Subject: [PATCH 45/68] Fully revert to original validate_endpoints --- pandas/core/arrays/datetimelike.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 38f708ca0a967..1f1c118b559ba 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1840,19 +1840,42 @@ def validate_periods(periods): return periods +def validate_periods(periods): + """ + If a `periods` argument is passed to the Datetime/Timedelta Array/Index + constructor, cast it to an integer. + Parameters + ---------- + periods : None, float, int + Returns + ------- + periods : None or int + Raises + ------ + TypeError + if periods is None, float, or int + """ + if periods is not None: + if lib.is_float(periods): + periods = int(periods) + elif not lib.is_integer(periods): + raise TypeError(f"periods must be a number, got {periods}") + return periods + + def validate_endpoints(closed): """ Check that the `closed` argument is among [None, "left", "right"] - + Parameters ---------- closed : {None, "left", "right"} - + Returns ------- left_closed : bool right_closed : bool - + Raises ------ ValueError : if argument is not among valid values From 0056f82b40724ab1bba2497ea2a0bc2d420fd02f Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Wed, 2 Jun 2021 23:33:12 -0600 Subject: [PATCH 46/68] Remove validate_periods --- pandas/core/arrays/datetimelike.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 45abb76529e6f..286fd8bf8ba4a 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1825,29 +1825,6 @@ def validate_periods(periods): return periods -def validate_periods(periods): - """ - If a `periods` argument is passed to the Datetime/Timedelta Array/Index - constructor, cast it to an integer. - Parameters - ---------- - periods : None, float, int - Returns - ------- - periods : None or int - Raises - ------ - TypeError - if periods is None, float, or int - """ - if periods is not None: - if lib.is_float(periods): - periods = int(periods) - elif not lib.is_integer(periods): - raise TypeError(f"periods must be a number, got {periods}") - return periods - - def validate_endpoints(closed): """ Check that the `closed` argument is among [None, "left", "right"] From a34ae5efc2ad4794e34b5dd3211048c6247c9f44 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Wed, 2 Jun 2021 23:38:55 -0600 Subject: [PATCH 47/68] Update pandas/core/series.py ValueError message Co-authored-by: attack68 <24256554+attack68@users.noreply.github.com> --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 1b33c5283ed2f..6a3a393f8284e 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5018,7 +5018,7 @@ def between(self, left, right, inclusive="both") -> Series: else: raise ValueError( "Inclusive has to be either string of 'both','left', 'right', " - "or 'neither', or a boolean value" + "or 'neither'" ) return lmask & rmask From 8279545918dcabbc835aabd27218b56af49ec66f Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Wed, 2 Jun 2021 23:40:45 -0600 Subject: [PATCH 48/68] Separate handling of individual inclusive parameters Co-authored-by: attack68 <24256554+attack68@users.noreply.github.com> --- pandas/core/series.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 6a3a393f8284e..a6d748f523186 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5012,7 +5012,15 @@ def between(self, left, right, inclusive="both") -> Series: elif inclusive == "right": lmask = self > left rmask = self <= right - elif inclusive == "neither" or inclusive is False: + elif inclusive == "neither": + lmask = self > left + rmask = self < right + elif inclusive is False: + warnings.warn( + "Boolean inputs to the `inclusive` argument are deprecated in favour of `{"both", or "neither"}`", + FutureWarning, + stacklevel=2, + ) lmask = self > left rmask = self < right else: From 2aed02feb0851d1401baff1013eb299b9c18161f Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Wed, 2 Jun 2021 23:50:09 -0600 Subject: [PATCH 49/68] Deprecate parameter description in inclusive --- pandas/core/series.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 1b33c5283ed2f..2eef8fcf34c3d 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4947,8 +4947,7 @@ def between(self, left, right, inclusive="both") -> Series: Right boundary. inclusive : {"both", "neither", "left", "right"} Include boundaries. Whether to set each bound as closed or open. - For backwards compatibility this can also be set to ``True`` - ("both") or false ("neither") + Deprecate boolean values of ``True`` ("both") or false ("neither"). .. versionchanged:: 1.3.0 From e8ba805650eecb4d9f074ac9cddde70ce6798888 Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Sun, 6 Jun 2021 23:57:59 -0600 Subject: [PATCH 50/68] Black reformatting --- pandas/tests/series/methods/test_between.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index e7c5fd9388a49..7b965b6ba79c6 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -40,8 +40,7 @@ def test_between_period_values(self): expected = (ser >= left) & (ser <= right) tm.assert_series_equal(result, expected) - # :issue:`40628` - def test_between_inclusive_is_boolean_string(self): + def test_between_inclusive_is_boolean_string(self): # :issue:`40628` series = Series(date_range("1/1/2000", periods=10)) left, right = series[[2, 7]] From 83d79f17e7898e8c44409664628e5e8a46c2f5b9 Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Mon, 7 Jun 2021 00:08:56 -0600 Subject: [PATCH 51/68] Split up line too long --- pandas/core/series.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 935751411f373..06964bd1ccba5 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4947,7 +4947,7 @@ def between(self, left, right, inclusive="both") -> Series: Right boundary. inclusive : {"both", "neither", "left", "right"} Include boundaries. Whether to set each bound as closed or open. - Deprecate boolean values of ``True`` ("both") or false ("neither"). + Boolean inputs to this argument are deprecated as of version 1.3.0. .. versionchanged:: 1.3.0 @@ -5016,7 +5016,8 @@ def between(self, left, right, inclusive="both") -> Series: rmask = self < right elif inclusive is False: warnings.warn( - "Boolean inputs to the `inclusive` argument are deprecated in favour of `{"both", or "neither"}`", + "Boolean inputs to the `inclusive` argument are deprecated in" + "favour of `both` or `neither`.", FutureWarning, stacklevel=2, ) From c2399cc6c1d143d4a5b310e46c88c0eeaffc50d7 Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Mon, 7 Jun 2021 00:10:53 -0600 Subject: [PATCH 52/68] Add FutureWarning for inclusive is true --- pandas/core/series.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 06964bd1ccba5..13940acb8ca91 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5002,7 +5002,7 @@ def between(self, left, right, inclusive="both") -> Series: dtype: bool """ - if inclusive == "both" or inclusive is True: + if inclusive == "both": lmask = self >= left rmask = self <= right elif inclusive == "left": @@ -5023,6 +5023,15 @@ def between(self, left, right, inclusive="both") -> Series: ) lmask = self > left rmask = self < right + elif inclusive is True: + warnings.warn( + "Boolean inputs to the `inclusive` argument are deprecated in" + "favour of `both` or `neither`.", + FutureWarning, + stacklevel=2, + ) + lmask = self >= left + rmask = self <= right else: raise ValueError( "Inclusive has to be either string of 'both','left', 'right', " From 842aaf7e06641638932554c02b857b04348bcc0c Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Mon, 7 Jun 2021 00:56:16 -0600 Subject: [PATCH 53/68] Black reformatting --- pandas/core/series.py | 4 ++-- pandas/tests/series/methods/test_between.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 13940acb8ca91..dc68ded90521d 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5034,8 +5034,8 @@ def between(self, left, right, inclusive="both") -> Series: rmask = self <= right else: raise ValueError( - "Inclusive has to be either string of 'both','left', 'right', " - "or 'neither'" + "Inclusive has to be either string of 'both'," + "'left', 'right', or 'neither'." ) return lmask & rmask diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index 7b965b6ba79c6..7b130c83a9b87 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -68,8 +68,14 @@ def test_between_inclusive_is_boolean_string(self): # :issue:`40628` expected = (series > left) & (series < right) tm.assert_series_equal(result, expected) - value_error_msg = """"Inclusive has to be either string of 'both', - 'left', 'right', or 'neither', or a boolean value""" + def test_between_error_args(self): # :issue:`40628` + series = Series(date_range("1/1/2000", periods=10)) + left, right = series[[2, 7]] + + value_error_msg = ( + "Inclusive has to be either string of 'both'," + "'left', 'right', or 'neither'." + ) with pytest.raises(ValueError, match=value_error_msg): series = Series(date_range("1/1/2000", periods=10)) From 8d68363040d111a7535b4d65d42affd2bf72291a Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Mon, 7 Jun 2021 00:57:39 -0600 Subject: [PATCH 54/68] Add FutureWarning test case Co-authored-by: attack68 <24256554+attack68@users.noreply.github.com> --- pandas/tests/series/methods/test_between.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index 7b130c83a9b87..cdc4440ea3a4c 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -80,3 +80,11 @@ def test_between_error_args(self): # :issue:`40628` with pytest.raises(ValueError, match=value_error_msg): series = Series(date_range("1/1/2000", periods=10)) series.between(left, right, inclusive="yes") + + def test_between_inclusive_warning(self): + series = Series(date_range("1/1/2000", periods=10)) + left, right = series[[2, 7]] + with tm.assert_produces_warning(FutureWarning): + result = series.between(left, right, inclusive=False) + with tm.assert_produces_warning(FutureWarning): + result = series.between(left, right, inclusive=True) From b4dc97975e502277f5b282dc00afd8a6c63abe20 Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Mon, 7 Jun 2021 01:08:15 -0600 Subject: [PATCH 55/68] Between inclusive warning test --- pandas/tests/series/methods/test_between.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index cdc4440ea3a4c..fb45c6e51f993 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -80,11 +80,11 @@ def test_between_error_args(self): # :issue:`40628` with pytest.raises(ValueError, match=value_error_msg): series = Series(date_range("1/1/2000", periods=10)) series.between(left, right, inclusive="yes") - - def test_between_inclusive_warning(self): - series = Series(date_range("1/1/2000", periods=10)) - left, right = series[[2, 7]] - with tm.assert_produces_warning(FutureWarning): - result = series.between(left, right, inclusive=False) - with tm.assert_produces_warning(FutureWarning): - result = series.between(left, right, inclusive=True) + + def test_between_inclusive_warning(self): + series = Series(date_range("1/1/2000", periods=10)) + left, right = series[[2, 7]] + with tm.assert_produces_warning(FutureWarning): + series.between(left, right, inclusive=False) + with tm.assert_produces_warning(FutureWarning): + series.between(left, right, inclusive=True) From 6564c4d0cdde75202862c7d995c8c774f71e230f Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Wed, 9 Jun 2021 00:00:07 -0600 Subject: [PATCH 56/68] Move inclusive tests --- pandas/tests/series/methods/test_between.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index fb45c6e51f993..f3f7aac4669f6 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -60,14 +60,6 @@ def test_between_inclusive_is_boolean_string(self): # :issue:`40628` expected = (series > left) & (series < right) tm.assert_series_equal(result, expected) - result = series.between(left, right, inclusive=True) - expected = (series >= left) & (series <= right) - tm.assert_series_equal(result, expected) - - result = series.between(left, right, inclusive=False) - expected = (series > left) & (series < right) - tm.assert_series_equal(result, expected) - def test_between_error_args(self): # :issue:`40628` series = Series(date_range("1/1/2000", periods=10)) left, right = series[[2, 7]] @@ -85,6 +77,10 @@ def test_between_inclusive_warning(self): series = Series(date_range("1/1/2000", periods=10)) left, right = series[[2, 7]] with tm.assert_produces_warning(FutureWarning): - series.between(left, right, inclusive=False) + result = series.between(left, right, inclusive=False) + expected = (series > left) & (series < right) + tm.assert_series_equal(result, expected) with tm.assert_produces_warning(FutureWarning): - series.between(left, right, inclusive=True) + result = series.between(left, right, inclusive=True) + expected = (series >= left) & (series <= right) + tm.assert_series_equal(result, expected) From 3321e575df8d3c000c397db913574d213bb68b6b Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Wed, 9 Jun 2021 00:03:26 -0600 Subject: [PATCH 57/68] Rename test_between_inclusive_is_boolean_string --- pandas/tests/series/methods/test_between.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index f3f7aac4669f6..dcfe7d4923b2f 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -40,7 +40,7 @@ def test_between_period_values(self): expected = (ser >= left) & (ser <= right) tm.assert_series_equal(result, expected) - def test_between_inclusive_is_boolean_string(self): # :issue:`40628` + def test_between_inclusive_string(self): # :issue:`40628` series = Series(date_range("1/1/2000", periods=10)) left, right = series[[2, 7]] From 697a5e9a45c62418e0c577f0a5d88635abcbf70d Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Wed, 9 Jun 2021 13:01:46 -0600 Subject: [PATCH 58/68] Handle boolean statements separately first --- pandas/core/series.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 51b260ce6e252..41e6db1fb3c75 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5041,7 +5041,17 @@ def between(self, left, right, inclusive="both") -> Series: 3 False dtype: bool """ - + if inclusive is True or inclusive is False: + warnings.warn( + "Boolean inputs to the `inclusive` argument are deprecated in" + "favour of `both` or `neither`.", + FutureWarning, + stacklevel=2, + ) + if inclusive: + inclusive = "both" + else: + inclusive = "neither" if inclusive == "both": lmask = self >= left rmask = self <= right @@ -5054,24 +5064,6 @@ def between(self, left, right, inclusive="both") -> Series: elif inclusive == "neither": lmask = self > left rmask = self < right - elif inclusive is False: - warnings.warn( - "Boolean inputs to the `inclusive` argument are deprecated in" - "favour of `both` or `neither`.", - FutureWarning, - stacklevel=2, - ) - lmask = self > left - rmask = self < right - elif inclusive is True: - warnings.warn( - "Boolean inputs to the `inclusive` argument are deprecated in" - "favour of `both` or `neither`.", - FutureWarning, - stacklevel=2, - ) - lmask = self >= left - rmask = self <= right else: raise ValueError( "Inclusive has to be either string of 'both'," From 98b6c8d202ca9bf1aa1c67e8874eea8242a766b1 Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Wed, 9 Jun 2021 13:19:36 -0600 Subject: [PATCH 59/68] Add code backtics --- doc/source/whatsnew/v1.3.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index b6d2c6cc322aa..fd258c15c7279 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -235,6 +235,7 @@ Other enhancements - Add keyword ``dropna`` to :meth:`DataFrame.value_counts` to allow counting rows that include ``NA`` values (:issue:`41325`) - :meth:`Series.replace` will now cast results to ``PeriodDtype`` where possible instead of ``object`` dtype (:issue:`41526`) - Improved error message in ``corr`` and ``cov`` methods on :class:`.Rolling`, :class:`.Expanding`, and :class:`.ExponentialMovingWindow` when ``other`` is not a :class:`DataFrame` or :class:`Series` (:issue:`41741`) +- :meth:`Series.between` can now accept ``left`` or ``right`` as arguments to ``inclusive`` to include only the left or right boundary .. --------------------------------------------------------------------------- From f57abf19e187188af2ac74da55909b48508c1e1a Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Sat, 12 Jun 2021 19:45:30 -0600 Subject: [PATCH 60/68] Remove depracation sentence from docstring --- pandas/core/series.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 41e6db1fb3c75..e430e3298ba3a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4987,7 +4987,6 @@ def between(self, left, right, inclusive="both") -> Series: Right boundary. inclusive : {"both", "neither", "left", "right"} Include boundaries. Whether to set each bound as closed or open. - Boolean inputs to this argument are deprecated as of version 1.3.0. .. versionchanged:: 1.3.0 From 13e2b6af91ae13b5713aa71de82f6e66a04dcbf4 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Thu, 17 Jun 2021 16:55:07 -0600 Subject: [PATCH 61/68] Add issue number to whatsnew --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index fefd8ffb8af26..a89cafe316de9 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -270,7 +270,7 @@ Other enhancements - Add keyword ``dropna`` to :meth:`DataFrame.value_counts` to allow counting rows that include ``NA`` values (:issue:`41325`) - :meth:`Series.replace` will now cast results to ``PeriodDtype`` where possible instead of ``object`` dtype (:issue:`41526`) - Improved error message in ``corr`` and ``cov`` methods on :class:`.Rolling`, :class:`.Expanding`, and :class:`.ExponentialMovingWindow` when ``other`` is not a :class:`DataFrame` or :class:`Series` (:issue:`41741`) -- :meth:`Series.between` can now accept ``left`` or ``right`` as arguments to ``inclusive`` to include only the left or right boundary +- :meth:`Series.between` can now accept ``left`` or ``right`` as arguments to ``inclusive`` to include only the left or right boundary (:issue:`40245`) .. --------------------------------------------------------------------------- From f11a078a1f26d7a43cc1a9d19fdcb64f395a1c77 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Fri, 18 Jun 2021 23:15:10 -0600 Subject: [PATCH 62/68] Revert whatsnew to main --- doc/source/whatsnew/v1.3.0.rst | 60 ++-------------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index cf6e43af6b674..1ddefc94bcbad 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -138,6 +138,7 @@ which has been revised and improved (:issue:`39720`, :issue:`39317`, :issue:`404 - Added the option ``styler.render.max_elements`` to avoid browser overload when styling large DataFrames (:issue:`40712`) - Added the method :meth:`.Styler.to_latex` (:issue:`21673`), which also allows some limited CSS conversion (:issue:`40731`) - Added the method :meth:`.Styler.to_html` (:issue:`13379`) + - Added the method :meth:`.Styler.set_sticky` to make index and column headers permanently visible in scrolling HTML frames (:issue:`29072`) .. _whatsnew_130.enhancements.dataframe_honors_copy_with_dict: @@ -274,7 +275,6 @@ Other enhancements - Add keyword ``dropna`` to :meth:`DataFrame.value_counts` to allow counting rows that include ``NA`` values (:issue:`41325`) - :meth:`Series.replace` will now cast results to ``PeriodDtype`` where possible instead of ``object`` dtype (:issue:`41526`) - Improved error message in ``corr`` and ``cov`` methods on :class:`.Rolling`, :class:`.Expanding`, and :class:`.ExponentialMovingWindow` when ``other`` is not a :class:`DataFrame` or :class:`Series` (:issue:`41741`) -- :meth:`Series.between` can now accept ``left`` or ``right`` as arguments to ``inclusive`` to include only the left or right boundary (:issue:`40245`) .. --------------------------------------------------------------------------- @@ -716,63 +716,6 @@ Build Deprecations ~~~~~~~~~~~~ -- Deprecated allowing scalars to be passed to the :class:`Categorical` constructor (:issue:`38433`) -- Deprecated constructing :class:`CategoricalIndex` without passing list-like data (:issue:`38944`) -- Deprecated allowing subclass-specific keyword arguments in the :class:`Index` constructor, use the specific subclass directly instead (:issue:`14093`, :issue:`21311`, :issue:`22315`, :issue:`26974`) -- Deprecated the :meth:`astype` method of datetimelike (``timedelta64[ns]``, ``datetime64[ns]``, ``Datetime64TZDtype``, ``PeriodDtype``) to convert to integer dtypes, use ``values.view(...)`` instead (:issue:`38544`) -- Deprecated :meth:`MultiIndex.is_lexsorted` and :meth:`MultiIndex.lexsort_depth`, use :meth:`MultiIndex.is_monotonic_increasing` instead (:issue:`32259`) -- Deprecated keyword ``try_cast`` in :meth:`Series.where`, :meth:`Series.mask`, :meth:`DataFrame.where`, :meth:`DataFrame.mask`; cast results manually if desired (:issue:`38836`) -- Deprecated comparison of :class:`Timestamp` objects with ``datetime.date`` objects. Instead of e.g. ``ts <= mydate`` use ``ts <= pd.Timestamp(mydate)`` or ``ts.date() <= mydate`` (:issue:`36131`) -- Deprecated :attr:`Rolling.win_type` returning ``"freq"`` (:issue:`38963`) -- Deprecated :attr:`Rolling.is_datetimelike` (:issue:`38963`) -- Deprecated :class:`DataFrame` indexer for :meth:`Series.__setitem__` and :meth:`DataFrame.__setitem__` (:issue:`39004`) -- Deprecated :meth:`ExponentialMovingWindow.vol` (:issue:`39220`) -- Using ``.astype`` to convert between ``datetime64[ns]`` dtype and :class:`DatetimeTZDtype` is deprecated and will raise in a future version, use ``obj.tz_localize`` or ``obj.dt.tz_localize`` instead (:issue:`38622`) -- Deprecated casting ``datetime.date`` objects to ``datetime64`` when used as ``fill_value`` in :meth:`DataFrame.unstack`, :meth:`DataFrame.shift`, :meth:`Series.shift`, and :meth:`DataFrame.reindex`, pass ``pd.Timestamp(dateobj)`` instead (:issue:`39767`) -- Deprecated :meth:`.Styler.set_na_rep` and :meth:`.Styler.set_precision` in favour of :meth:`.Styler.format` with ``na_rep`` and ``precision`` as existing and new input arguments respectively (:issue:`40134`, :issue:`40425`) -- Deprecated allowing partial failure in :meth:`Series.transform` and :meth:`DataFrame.transform` when ``func`` is list-like or dict-like and raises anything but ``TypeError``; ``func`` raising anything but a ``TypeError`` will raise in a future version (:issue:`40211`) -- Deprecated arguments ``error_bad_lines`` and ``warn_bad_lines`` in :meth:`read_csv` and :meth:`read_table` in favor of argument ``on_bad_lines`` (:issue:`15122`) -- Deprecated support for ``np.ma.mrecords.MaskedRecords`` in the :class:`DataFrame` constructor, pass ``{name: data[name] for name in data.dtype.names}`` instead (:issue:`40363`) -- Deprecated using :func:`merge`, :meth:`DataFrame.merge`, and :meth:`DataFrame.join` on a different number of levels (:issue:`34862`) -- Deprecated the use of ``**kwargs`` in :class:`.ExcelWriter`; use the keyword argument ``engine_kwargs`` instead (:issue:`40430`) -- Deprecated the ``level`` keyword for :class:`DataFrame` and :class:`Series` aggregations; use groupby instead (:issue:`39983`) -- Deprecated the ``inplace`` parameter of :meth:`Categorical.remove_categories`, :meth:`Categorical.add_categories`, :meth:`Categorical.reorder_categories`, :meth:`Categorical.rename_categories`, :meth:`Categorical.set_categories` and will be removed in a future version (:issue:`37643`) -- Deprecated :func:`merge` producing duplicated columns through the ``suffixes`` keyword and already existing columns (:issue:`22818`) -- Deprecated boolean arguments of ``inclusive`` in :meth:`Series.between` to have ``{"left", "right", "neither", "both"}`` as standard argument values (:issue:`40628`) -- Deprecated setting :attr:`Categorical._codes`, create a new :class:`Categorical` with the desired codes instead (:issue:`40606`) -- Deprecated the ``convert_float`` optional argument in :func:`read_excel` and :meth:`ExcelFile.parse` (:issue:`41127`) -- Deprecated behavior of :meth:`DatetimeIndex.union` with mixed timezones; in a future version both will be cast to UTC instead of object dtype (:issue:`39328`) -- Deprecated using ``usecols`` with out of bounds indices for :func:`read_csv` with ``engine="c"`` (:issue:`25623`) -- Deprecated passing arguments as positional (except for ``"codes"``) in :meth:`MultiIndex.codes` (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`Index.set_names` and :meth:`MultiIndex.set_names` (except for ``names``) (:issue:`41485`) -- Deprecated passing arguments (apart from ``cond`` and ``other``) as positional in :meth:`DataFrame.mask` and :meth:`Series.mask` (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`Resampler.interpolate` (other than ``"method"``) (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`DataFrame.clip` and :meth:`Series.clip` (other than ``"upper"`` and ``"lower"``) (:issue:`41485`) -- Deprecated special treatment of lists with first element a Categorical in the :class:`DataFrame` constructor; pass as ``pd.DataFrame({col: categorical, ...})`` instead (:issue:`38845`) -- Deprecated behavior of :class:`DataFrame` constructor when a ``dtype`` is passed and the data cannot be cast to that dtype. In a future version, this will raise instead of being silently ignored (:issue:`24435`) -- Deprecated passing arguments as positional (except for ``"method"``) in :meth:`DataFrame.interpolate` and :meth:`Series.interpolate` (:issue:`41485`) -- Deprecated the :attr:`Timestamp.freq` attribute. For the properties that use it (``is_month_start``, ``is_month_end``, ``is_quarter_start``, ``is_quarter_end``, ``is_year_start``, ``is_year_end``), when you have a ``freq``, use e.g. ``freq.is_month_start(ts)`` (:issue:`15146`) -- Deprecated passing arguments as positional in :meth:`DataFrame.ffill`, :meth:`Series.ffill`, :meth:`DataFrame.bfill`, and :meth:`Series.bfill` (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`DataFrame.sort_values` (other than ``"by"``) and :meth:`Series.sort_values` (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`DataFrame.dropna` and :meth:`Series.dropna` (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`DataFrame.set_index` (other than ``"keys"``) (:issue:`41485`) -- Deprecated passing arguments as positional (except for ``"levels"``) in :meth:`MultiIndex.set_levels` (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`DataFrame.sort_index` and :meth:`Series.sort_index` (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`DataFrame.drop_duplicates` (except for ``subset``), :meth:`Series.drop_duplicates`, :meth:`Index.drop_duplicates` and :meth:`MultiIndex.drop_duplicates` (:issue:`41485`) -- Deprecated passing arguments (apart from ``value``) as positional in :meth:`DataFrame.fillna` and :meth:`Series.fillna` (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`DataFrame.reset_index` (other than ``"level"``) and :meth:`Series.reset_index` (:issue:`41485`) -- Deprecated construction of :class:`Series` or :class:`DataFrame` with ``DatetimeTZDtype`` data and ``datetime64[ns]`` dtype. Use ``Series(data).dt.tz_localize(None)`` instead (:issue:`41555`, :issue:`33401`) -- Deprecated behavior of :class:`Series` construction with large-integer values and small-integer dtype silently overflowing; use ``Series(data).astype(dtype)`` instead (:issue:`41734`) -- Deprecated behavior of :class:`DataFrame` construction with floating data and integer dtype casting even when lossy; in a future version this will remain floating, matching :class:`Series` behavior (:issue:`41770`) -- Deprecated inference of ``timedelta64[ns]``, ``datetime64[ns]``, or ``DatetimeTZDtype`` dtypes in :class:`Series` construction when data containing strings is passed and no ``dtype`` is passed (:issue:`33558`) -- In a future version, constructing :class:`Series` or :class:`DataFrame` with ``datetime64[ns]`` data and ``DatetimeTZDtype`` will treat the data as wall-times instead of as UTC times (matching DatetimeIndex behavior). To treat the data as UTC times, use ``pd.Series(data).dt.tz_localize("UTC").dt.tz_convert(dtype.tz)`` or ``pd.Series(data.view("int64"), dtype=dtype)`` (:issue:`33401`) -- Deprecated passing arguments as positional in :meth:`DataFrame.set_axis` and :meth:`Series.set_axis` (other than ``"labels"``) (:issue:`41485`) -- Deprecated passing arguments as positional in :meth:`DataFrame.where` and :meth:`Series.where` (other than ``"cond"`` and ``"other"``) (:issue:`41485`) -- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_csv` (:issue:`41485`) -- Deprecated passing lists as ``key`` to :meth:`DataFrame.xs` and :meth:`Series.xs` (:issue:`41760`) -- Deprecated passing arguments as positional in :meth:`DataFrame.drop` (other than ``"labels"``) and :meth:`Series.drop` (:issue:`41485`) -- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_table` (:issue:`41485`) -- Deprecated passing arguments as positional (other than ``objs``) in :func:`concat` (:issue:`41485`) .. _whatsnew_130.deprecations.nuisance_columns: @@ -1272,6 +1215,7 @@ Other - Bug in :class:`Series` backed by :class:`DatetimeArray` or :class:`TimedeltaArray` sometimes failing to set the array's ``freq`` to ``None`` (:issue:`41425`) - Bug in creating a :class:`Series` from a ``range`` object that does not fit in the bounds of ``int64`` dtype (:issue:`30173`) - Bug in creating a :class:`Series` from a ``dict`` with all-tuple keys and an :class:`Index` that requires reindexing (:issue:`41707`) +- Bug in :func:`pandas.util.hash_pandas_object` not recognizing ``hash_key``, ``encoding`` and ``categorize`` when the input object type is a :class:`DataFrame` (:issue:`41404`) .. --------------------------------------------------------------------------- From 9508c15cbc21c1d14223b659a0d7a345fdaf08d3 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Fri, 18 Jun 2021 23:21:03 -0600 Subject: [PATCH 63/68] Readd entry to enhancements --- doc/source/whatsnew/v1.3.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 1ddefc94bcbad..9a9eaa1750218 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -275,6 +275,7 @@ Other enhancements - Add keyword ``dropna`` to :meth:`DataFrame.value_counts` to allow counting rows that include ``NA`` values (:issue:`41325`) - :meth:`Series.replace` will now cast results to ``PeriodDtype`` where possible instead of ``object`` dtype (:issue:`41526`) - Improved error message in ``corr`` and ``cov`` methods on :class:`.Rolling`, :class:`.Expanding`, and :class:`.ExponentialMovingWindow` when ``other`` is not a :class:`DataFrame` or :class:`Series` (:issue:`41741`) +- :meth:`Series.between` can now accept ``left`` or ``right`` as arguments to ``inclusive`` to include only the left or right boundary (:issue:`40245`) .. --------------------------------------------------------------------------- From 10a609c3433f9ab282548157bf850f5fee2d3b33 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Fri, 18 Jun 2021 23:23:51 -0600 Subject: [PATCH 64/68] Readd entry to deprecations --- doc/source/whatsnew/v1.3.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 9a9eaa1750218..ad9f696c463a5 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -837,6 +837,7 @@ Other Deprecations - Deprecated inference of ``timedelta64[ns]``, ``datetime64[ns]``, or ``DatetimeTZDtype`` dtypes in :class:`Series` construction when data containing strings is passed and no ``dtype`` is passed (:issue:`33558`) - In a future version, constructing :class:`Series` or :class:`DataFrame` with ``datetime64[ns]`` data and ``DatetimeTZDtype`` will treat the data as wall-times instead of as UTC times (matching DatetimeIndex behavior). To treat the data as UTC times, use ``pd.Series(data).dt.tz_localize("UTC").dt.tz_convert(dtype.tz)`` or ``pd.Series(data.view("int64"), dtype=dtype)`` (:issue:`33401`) - Deprecated passing lists as ``key`` to :meth:`DataFrame.xs` and :meth:`Series.xs` (:issue:`41760`) +- Deprecated boolean arguments of ``inclusive`` in :meth:`Series.between` to have ``{"left", "right", "neither", "both"}`` as standard argument values (:issue:`40628`) - Deprecated passing arguments as positional for all of the following, with exceptions noted (:issue:`41485`): - :func:`concat` (other than ``objs``) From 238bd1debcdc3ef95f59367649e262e1ae9a3176 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Fri, 18 Jun 2021 23:26:35 -0600 Subject: [PATCH 65/68] Remove extraneous lines Remove lines that still appear by PR to be additions --- doc/source/whatsnew/v1.3.0.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index ad9f696c463a5..609e8819b0aec 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -138,7 +138,6 @@ which has been revised and improved (:issue:`39720`, :issue:`39317`, :issue:`404 - Added the option ``styler.render.max_elements`` to avoid browser overload when styling large DataFrames (:issue:`40712`) - Added the method :meth:`.Styler.to_latex` (:issue:`21673`), which also allows some limited CSS conversion (:issue:`40731`) - Added the method :meth:`.Styler.to_html` (:issue:`13379`) - - Added the method :meth:`.Styler.set_sticky` to make index and column headers permanently visible in scrolling HTML frames (:issue:`29072`) .. _whatsnew_130.enhancements.dataframe_honors_copy_with_dict: @@ -1217,7 +1216,6 @@ Other - Bug in :class:`Series` backed by :class:`DatetimeArray` or :class:`TimedeltaArray` sometimes failing to set the array's ``freq`` to ``None`` (:issue:`41425`) - Bug in creating a :class:`Series` from a ``range`` object that does not fit in the bounds of ``int64`` dtype (:issue:`30173`) - Bug in creating a :class:`Series` from a ``dict`` with all-tuple keys and an :class:`Index` that requires reindexing (:issue:`41707`) -- Bug in :func:`pandas.util.hash_pandas_object` not recognizing ``hash_key``, ``encoding`` and ``categorize`` when the input object type is a :class:`DataFrame` (:issue:`41404`) .. --------------------------------------------------------------------------- From b92bbdab49f3f457a6d67745f001ac718a4eb181 Mon Sep 17 00:00:00 2001 From: Kiley Hewitt <42876297+hewittk@users.noreply.github.com> Date: Mon, 21 Jun 2021 14:45:16 -0600 Subject: [PATCH 66/68] Update v1.3.0.rst --- doc/source/whatsnew/v1.3.0.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index ba2f8b1b1df39..29f35922fbf28 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -277,7 +277,6 @@ Other enhancements - :meth:`Series.replace` will now cast results to ``PeriodDtype`` where possible instead of ``object`` dtype (:issue:`41526`) - Improved error message in ``corr`` and ``cov`` methods on :class:`.Rolling`, :class:`.Expanding`, and :class:`.ExponentialMovingWindow` when ``other`` is not a :class:`DataFrame` or :class:`Series` (:issue:`41741`) - :meth:`Series.between` can now accept ``left`` or ``right`` as arguments to ``inclusive`` to include only the left or right boundary (:issue:`40245`) -======= - :meth:`DataFrame.explode` now supports exploding multiple columns. Its ``column`` argument now also accepts a list of str or tuples for exploding on multiple columns at the same time (:issue:`39240`) .. --------------------------------------------------------------------------- From 7911883f8cf18f1856e347076f30af6611dae9f6 Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Thu, 24 Jun 2021 16:24:45 -0600 Subject: [PATCH 67/68] Remove double line from docstring --- pandas/core/series.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 6084a4a5579c9..582e69a78e0bb 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4983,10 +4983,8 @@ def between(self, left, right, inclusive="both") -> Series: Right boundary. inclusive : {"both", "neither", "left", "right"} Include boundaries. Whether to set each bound as closed or open. - .. versionchanged:: 1.3.0 - Returns ------- Series From 733b5b24fecf3dd47e1b719b77b9fae69596e377 Mon Sep 17 00:00:00 2001 From: Kiley <42876297+hewittk@users.noreply.github.com> Date: Thu, 24 Jun 2021 21:52:31 -0600 Subject: [PATCH 68/68] Change inclusive argument in test suite --- pandas/tests/series/methods/test_between.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index dcfe7d4923b2f..9c11b71e4bee6 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -29,7 +29,7 @@ def test_between_datetime_values(self): expected = ser[3:18].dropna() tm.assert_series_equal(result, expected) - result = ser[ser.between(ser[3], ser[17], inclusive=False)] + result = ser[ser.between(ser[3], ser[17], inclusive="neither")] expected = ser[5:16].dropna() tm.assert_series_equal(result, expected)