ENH Add MultiIndex.from_product convenience function
State: closed

Following up on this [StackOverflow post](http://stackoverflow.com/questions/21316628/make-a-pandas-multiindex-from-a-product-of-iterables).

This is a convenience function for when you have a set of iterables and you want to make a MultiIndex with each unique paring of the values in those iterables.

~~I'm testing it against `itertools.product` since it uses the internal `cartesian_product` function; please let me know if there are additional tests that would make sense.~~

Testing against MultiIndex.from_tuples instead.


Labels:

Comments:
I have a remark about this. First, it's really usefull functionality! (it's indeed a common usecase)

But the name sounds confusing to me. Because it seems not that important that it are `iterables`, but that it's from a _cross combination_ of two iterables (you can also use iterables in `from_arrays/from_tuples`). For me it's not obvious that if you have iterables that you would logically take a product of it. 
But I admit I don't directly have that clear or short alternatives (`from_combination`, `from_product`, `from_iter_product`, `from_cartesias_product`, ..)

`from_product` :+1: 

@mwaskom FYI, use this PR number in release notes / v0.13.1 (as the reference issue)

OK, should be good

small changes

pls rebase and squash into 1 commit, see here: https://github.com/pydata/pandas/wiki/Using-Git

OK, sorry, git question.

I rebased and squashed, i.e. `git log` now shows

```
commit 493eb08fd59c4776b2a072b37646fef3aa09d661
Author: mwaskom <mwaskom@stanford.edu>
Date:   Thu Jan 23 18:57:22 2014 -0800

    ENH Add MultiIndex.from_product convenience function

    FIX typo in from_iterables docstring

    ENH Rename from_iterables to from_product

    TST rework from_product test to compare against from_tuples

    DOC Add notes on from_product to release notes and indexing docs

    DOC clean from_product examples in docs

commit b537df5f9d4a783f8edad20ce53968c74ad56985
Merge: 039c57d d6667b1
Author: jreback <jeff@reback.net>
Date:   Sat Jan 25 10:03:52 2014 -0800

    Merge pull request #6097 from jreback/hdf_fix

    TST: don't compare inferred index freq on some tests as it may not be preser
```

But now I cannot push to this branch due to

```
[pandas]{multiindex_from_iterables}$ git push origin multiindex_from_iterables
Username for 'https://github.com': mwaskom
Password for 'https://mwaskom@github.com':
To https://github.com/mwaskom/pandas.git
 ! [rejected]        multiindex_from_iterables -> multiindex_from_iterables (non-fast-forward)
error: failed to push some refs to 'https://github.com/mwaskom/pandas.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
```

What's the right thing to do?

try this

```
git fetch upstream/master
git rebase -i upstream/master
```

remove all but your commit

then

```
git push origin thisbranchname -f
```

(the `-f` force pushes)

OK that's what I thought but wasn't sure.

@mwaskom excellent git-fu

any other comments

@jorisvandenbossche 
@jtratner 

I think that addresses everything.

@jorisvandenbossche ok by me...go ahead and merge if you are ok

Yes, certainly fine. Thanks a lot @mwaskom !

I just reached for this and it was there. :+1: