Skip to content

BUG: Can't store callables using __setitem__ #13516

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 1, 2016

Conversation

evanpw
Copy link
Contributor

@evanpw evanpw commented Jun 26, 2016

@@ -4455,6 +4455,9 @@ def _align_series(self, other, join='outer', axis=None, level=None,
raise_on_error : boolean, default True
Whether to raise on invalid data types (e.g. trying to where on
strings)
apply_other : boolean, default True
If False, other will be stored directly rather than applied to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need another parameter
it's remove the callable check on other entirely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine with me; I left it in because @sinhrks wanted it for the case where "where" is called directly rather than through setitem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think we just shouldn't act on other at all.

Copy link
Member

@sinhrks sinhrks Jun 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding internal _where which doesn't apply callable at all? where can use it after applying callable.

I think applying callable to other in where is sometimes useful (described in #13299).

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves API Design labels Jun 26, 2016
@jreback
Copy link
Contributor

jreback commented Jun 28, 2016

yeah that's a better soln


@Appender(_shared_docs['where'] % dict(_shared_doc_kwargs, cond="True"))
def where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a docstring to this one explaining it's purpose?

@jreback jreback added this to the 0.18.2 milestone Jun 29, 2016
@jreback
Copy link
Contributor

jreback commented Jun 29, 2016

lgtm.

@jreback
Copy link
Contributor

jreback commented Jul 1, 2016

lgtm. @jorisvandenbossche

@@ -481,7 +481,7 @@ Bug Fixes
- Bug in ``.tz_convert`` on a tz-aware ``DateTimeIndex`` that relied on index being sorted for correct results (:issue:`13306`)
- Bug in ``pd.read_hdf()`` where attempting to load an HDF file with a single dataset, that had one or more categorical columns, failed unless the key argument was set to the name of the dataset. (:issue:`13231`)
- Bug in ``.rolling()`` that allowed a negative integer window in contruction of the ``Rolling()`` object, but would later fail on aggregation (:issue:`13383`)

- Bug in ``__setitem__`` causing a callable rhs to be applied rather than stored (:issue:`13299`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually maybe put this in API changes to make it a bit more prominent.

@codecov-io
Copy link

codecov-io commented Jul 1, 2016

Current coverage is 84.34%

Merging #13516 into master will increase coverage by <.01%

@@             master     #13516   diff @@
==========================================
  Files           138        138          
  Lines         51107      51113     +6   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43103      43109     +6   
  Misses         8004       8004          
  Partials          0          0          

Powered by Codecov. Last updated by bf4786a...2a6607a

@jorisvandenbossche jorisvandenbossche merged commit a01644c into pandas-dev:master Jul 1, 2016
@jorisvandenbossche
Copy link
Member

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: New callable indexing makes storing functions in a Series difficult
5 participants