Skip to content

API Consistency: validations on no-ops #36466

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

Open
1 task
jbrockmendel opened this issue Sep 19, 2020 · 2 comments
Open
1 task

API Consistency: validations on no-ops #36466

jbrockmendel opened this issue Sep 19, 2020 · 2 comments
Labels
API - Consistency Internal Consistency of API/Behavior Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Sep 19, 2020

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

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 19, 2020
@jreback
Copy link
Contributor

jreback commented Sep 19, 2020

+1 we should raise ultimately if we have an invalid value

so deprecation fine for now

@jbrockmendel jbrockmendel added API - Consistency Internal Consistency of API/Behavior and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 19, 2020
@jorisvandenbossche
Copy link
Member

It would indeed be nice to make this more consistent. Moving towards always raising on a invalid fill value sounds good.

What would you do for the second example? (series_dt64[empty_indexer] = empty_object_dtype # <-- we cast to object, meaning we did raise internally) Keep that behaviour?

@mroeschke mroeschke added the Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate label Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

No branches or pull requests

4 participants