Skip to content
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

Allow Panel arith methods for types other than scalars #4971

Closed
dalejung opened this issue Sep 24, 2013 · 5 comments
Closed

Allow Panel arith methods for types other than scalars #4971

dalejung opened this issue Sep 24, 2013 · 5 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Numeric Operations Arithmetic, Comparison, and Logical operations Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@dalejung
Copy link
Contributor

Taken from #4960

Currently Panel arith methods only work with scalars.

jreback@adf9d48

removes the explicit check, but need to make sure it works with tests.

@dalejung
Copy link
Contributor Author

@jreback Is there a general way to think about arith methods for NDFrames?

From what I can tell.

  1. If other is scalar, result should be the same as op(val, other) for every element in .values.
  2. Any array-like other must have self.ndim >= other.ndim
  3. If other is array-like but not an NDFrame, it must match the shape of axes it's applying to. Lower dim other will be broadcasted along the unused axis.
  4. If other is NDFrame, outer join the objects and then op the aligned objects. Lower dim other broadcast like regular array once alignment occurs.

I think those rules should be true for all NDFrames, regardless of dimensions. However, this breaks down in my head when it comes to #4 and Panel/4D.

DataFrame.mul(Series, axis='columns') can add a column in the resultant DataFrame.

However, Panel.mul(DataFrame, axis='items') could never expand items.

Is the issue that technically axis should be Panel.mul(DataFrame, axis=('major', 'minor') and we items as convenience? If we were multiplying a Panel4D by a DataFrame, how would we specify the axis?

Probably overthinking it but wanted a programatic way to test arith methods on all NDFrame subclasses.

@jreback
Copy link
Contributor

jreback commented Sep 24, 2013

see the _combine method, which tests each of these cases, e.g. scalar, series, frame, panel, > panel

and on anything > 2 dims we don't (or shouldn't) support an ndarray because its unclear how to align it (unless it exactly matches dims, so its clear) - I don't think is really tested either (though maybe combine falls thru and so it raises)

IOW, leary of doing any sort of automatic broadcasting with > 2 dims (except via specific .mul methods which provide a broadcasting axis)

as far as those go, there is a note in the docs about how wes decided to handle them, somewhere in basicas. (so i think you are right in that regards).

@jtratner
Copy link
Contributor

Hey all, please wait on this until after I refactor arithmetic. I'd rather you work on this after I've set up the general structure, rather than me having to wrap my head around something new and try not to break it while refactoring.

@jreback
Copy link
Contributor

jreback commented Sep 24, 2013

@jtratner no worries!

@dalejung you can certianly start working on tests if you would like in any event as they will be relevant

@jreback jreback modified the milestones: 0.15.0, 0.14.0 Mar 28, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 3, 2015
@jreback
Copy link
Contributor

jreback commented Jul 10, 2017

closing as Panels are deprecated

@jreback jreback closed this as completed Jul 10, 2017
@jreback jreback modified the milestones: Next Major Release, won't fix Jul 11, 2017
@TomAugspurger TomAugspurger modified the milestones: won't fix, No action Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Numeric Operations Arithmetic, Comparison, and Logical operations Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

5 participants