Skip to content

TYP: freq and na_value #47729

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 4 commits into from
Jul 18, 2022
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
4 changes: 3 additions & 1 deletion pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,9 @@ def validate_periods(periods: int | float | None) -> int | None:
return periods # type: ignore[return-value]


def validate_inferred_freq(freq, inferred_freq, freq_infer):
def validate_inferred_freq(
freq, inferred_freq, freq_infer
) -> tuple[BaseOffset | None, bool]:
"""
If the user passes a freq and another freq is inferred from passed data,
require that they match.
Expand Down
7 changes: 5 additions & 2 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ def _validate_dtype(cls, values, dtype):
# error: Signature of "_simple_new" incompatible with supertype "NDArrayBacked"
@classmethod
def _simple_new( # type: ignore[override]
cls, values: np.ndarray, freq: BaseOffset | None = None, dtype=DT64NS_DTYPE
cls,
values: np.ndarray,
freq: BaseOffset | None = None,
dtype=DT64NS_DTYPE,
) -> DatetimeArray:
assert isinstance(values, np.ndarray)
assert dtype.kind == "M"
Expand All @@ -291,7 +294,7 @@ def _from_sequence_not_strict(
dtype=None,
copy: bool = False,
tz=None,
freq=lib.no_default,
freq: str | BaseOffset | lib.NoDefault | None = lib.no_default,
dayfirst: bool = False,
yearfirst: bool = False,
ambiguous="raise",
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ def to_numpy(
self,
dtype: npt.DTypeLike | None = None,
copy: bool = False,
na_value=lib.no_default,
na_value: object = lib.no_default,
) -> np.ndarray:
"""
Convert the DataFrame to a NumPy array.
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
lib,
)
from pandas._libs.tslibs import (
BaseOffset,
Resolution,
periods_per_day,
timezones,
Expand Down Expand Up @@ -312,7 +313,7 @@ def isocalendar(self) -> DataFrame:
def __new__(
cls,
data=None,
freq=lib.no_default,
freq: str | BaseOffset | lib.NoDefault = lib.no_default,
tz=None,
normalize: bool = False,
closed=None,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/internals/array_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ def as_array(
self,
dtype=None,
copy: bool = False,
na_value=lib.no_default,
na_value: object = lib.no_default,
) -> np.ndarray:
"""
Convert the blockmanager data into an numpy array.
Expand Down