Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameters as either booleans or strings #2

Merged
merged 1 commit into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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":
Expand All @@ -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

Expand Down