Skip to content

CLN: assorted follow-ups #41772

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
Jun 2, 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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ Other API changes
- Partially initialized :class:`CategoricalDtype` (i.e. those with ``categories=None`` objects will no longer compare as equal to fully initialized dtype objects.
- Accessing ``_constructor_expanddim`` on a :class:`DataFrame` and ``_constructor_sliced`` on a :class:`Series` now raise an ``AttributeError``. Previously a ``NotImplementedError`` was raised (:issue:`38782`)
- Added new ``engine`` and ``**engine_kwargs`` parameters to :meth:`DataFrame.to_sql` to support other future "SQL engines". Currently we still only use ``SQLAlchemy`` under the hood, but more engines are planned to be supported such as ``turbodbc`` (:issue:`36893`)
- Removed redundant ``freq`` from :class:`PeriodIndex` string representation (:issue:`41653`)

Build
=====
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ def infer_dtype(value: object, skipna: bool = True) -> str:
for i in range(n):
val = values[i]

# do not use is_nul_datetimelike to keep
# do not use is_null_datetimelike to keep
# np.datetime64('nat') and np.timedelta64('nat')
if val is None or util.is_nan(val):
pass
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,14 +1266,14 @@ def compute(self, method: str) -> Series:
return dropped.sort_values(ascending=ascending).head(n)

# fast method
arr, pandas_dtype = _ensure_data(dropped.values)
arr, new_dtype = _ensure_data(dropped.values)
if method == "nlargest":
arr = -arr
if is_integer_dtype(pandas_dtype):
if is_integer_dtype(new_dtype):
# GH 21426: ensure reverse ordering at boundaries
arr -= 1

elif is_bool_dtype(pandas_dtype):
elif is_bool_dtype(new_dtype):
# GH 26154: ensure False is smaller than True
arr = 1 - (-arr)

Expand Down
1 change: 0 additions & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,6 @@ def sequence_to_dt64ns(
result = data.view(DT64NS_DTYPE)

if copy:
# TODO: should this be deepcopy?
result = result.copy()

assert isinstance(result, np.ndarray), type(result)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def start_time(self) -> DatetimeArray:
def end_time(self) -> DatetimeArray:
return self.to_timestamp(how="end")

def _require_matching_freq(self, other, base=False):
def _require_matching_freq(self, other, base: bool = False) -> None:
# See also arrays.period.raise_on_incompatible
if isinstance(other, BaseOffset):
other_freq = other
Expand Down Expand Up @@ -1057,7 +1057,7 @@ def dt64arr_to_periodarr(data, freq, tz=None):

Returns
-------
ordinals : ndarray[int]
ordinals : ndarray[int64]
freq : Tick
The frequency extracted from the Series or DatetimeIndex if that's
used.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ def _engine(self) -> libindex.IndexEngine:
target_values = self._get_engine_target()
return self._engine_type(lambda: target_values, len(self))

@final
@cache_readonly
def _dir_additions_for_owner(self) -> set[str_t]:
"""
Expand Down Expand Up @@ -6209,6 +6210,7 @@ def shape(self) -> Shape:
# See GH#27775, GH#27384 for history/reasoning in how this is defined.
return (len(self),)

@final
def _deprecated_arg(self, value, name: str_t, methodname: str_t) -> None:
"""
Issue a FutureWarning if the arg/kwarg is not no_default.
Expand Down