Skip to content

CLN: NDFrame._where, comment typos #37922

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 1 commit into from
Nov 18, 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
12 changes: 5 additions & 7 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9020,7 +9020,6 @@ def _where(
cond = -cond if inplace else cond

# try to align with other
try_quick = True
if isinstance(other, NDFrame):

# align with me
Expand Down Expand Up @@ -9059,12 +9058,11 @@ def _where(
# match True cond to other
elif len(cond[icond]) == len(other):

# try to not change dtype at first (if try_quick)
if try_quick:
new_other = np.asarray(self)
new_other = new_other.copy()
new_other[icond] = other
other = new_other
# try to not change dtype at first
new_other = np.asarray(self)
new_other = new_other.copy()
new_other[icond] = other
other = new_other

else:
raise ValueError(
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,7 @@ def where(
if values.ndim - 1 == other.ndim and axis == 1:
other = other.reshape(tuple(other.shape + (1,)))
elif transpose and values.ndim == self.ndim - 1:
# TODO(EA2D): not neceesssary with 2D EAs
cond = cond.T

if not hasattr(cond, "shape"):
Expand Down Expand Up @@ -2413,9 +2414,8 @@ def _can_hold_element(self, element: Any) -> bool:
return is_valid_nat_for_dtype(element, self.dtype)

def fillna(self, value, **kwargs):

# allow filling with integers to be
# interpreted as nanoseconds
# TODO(EA2D): if we operated on array_values, TDA.fillna would handle
# raising here.
if is_integer(value):
# Deprecation GH#24694, GH#19233
raise TypeError(
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def __setitem__(self, key, value):
# positional setter
values[key] = value
else:
# GH#12862 adding an new key to the Series
# GH#12862 adding a new key to the Series
self.loc[key] = value

except TypeError as err:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def test_align_date_objects_with_datetimeindex(self):
@pytest.mark.parametrize("box", [list, tuple, np.array, pd.Index, pd.Series, pd.array])
@pytest.mark.parametrize("flex", [True, False])
def test_series_ops_name_retention(flex, box, names, all_binary_operators):
# GH#33930 consistent name renteiton
# GH#33930 consistent name retention
op = all_binary_operators

if op is ops.rfloordiv and box in [list, tuple]:
Expand Down