Skip to content

CLN: misc cleanups #30877

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

Merged
merged 8 commits into from
Jan 13, 2020
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
2 changes: 0 additions & 2 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ cdef class IndexEngine:
"""
cdef:
object loc
void* data_ptr

loc = self.get_loc(key)
if isinstance(loc, slice) or util.is_array(loc):
Expand All @@ -101,7 +100,6 @@ cdef class IndexEngine:
"""
cdef:
object loc
void* data_ptr

loc = self.get_loc(key)
value = convert_scalar(arr, value)
Expand Down
14 changes: 4 additions & 10 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ def equals(self, other) -> bool:
def __contains__(self, key):
try:
res = self.get_loc(key)
return (
is_scalar(res)
or isinstance(res, slice)
or (is_list_like(res) and len(res))
)
except (KeyError, TypeError, ValueError):
return False
return bool(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the bool redundant here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not according to mypy

is_scalar(res) or isinstance(res, slice) or (is_list_like(res) and len(res))
)

# Try to run function on index first, and then on elements of index
# Especially important for group-by functionality
Expand Down Expand Up @@ -875,11 +873,7 @@ def _is_convertible_to_index_for_join(cls, other: Index) -> bool:

def _wrap_joined_index(self, joined, other):
name = get_op_result_name(self, other)
if (
isinstance(other, type(self))
and self.freq == other.freq
and self._can_fast_union(other)
):
if self._can_fast_union(other):
joined = self._shallow_copy(joined)
joined.name = name
return joined
Expand Down