Skip to content

API Consistency: validations on no-ops #36466

Open
@jbrockmendel

Description

@jbrockmendel

We are not consistent about whether we do validation checks on no-ops

Examples of no-ops:

  • datetimelike_array[empty_indexer] = empty_values_wrong_dtype # <-- we do not raise
  • series_dt64[empty_indexer] = empty_object_dtype # <-- we cast to object, meaning we did raise internally
  • arr_with_no_nas.fillna(invalid_fill_value) # <-- we mostly dont raise, see below
  • interval_index.take(indexer_with_no_negative_ones, fill_value=something_invalid) # <-- we do not raise
pd.array([1, 4, 6]).fillna("foo")
pd.array([1.0, 4.9, 6.0]).fillna("foo")

pd.IntervalIndex.from_breaks(range(3)).fillna("foo")

dti = pd.date_range("2016-01-01", periods=3)
dti.fillna("foo")
(dti - dti).fillna("foo")
dti.to_period("D").fillna("foo")

pd.Categorical(dti).fillna("foo")   <-- raises

I think we should (with deprecation cycles where necessary) aim to be consistently strict in this genre of check.

Update: listing related issues as I find them

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions