Repository: pandas-dev/pandas

Issue:
ENH/CLN: Make df.pivot to the mapping of pivot_table
Related to #6913.

`DataFrame.pivot` function uses separate logic and has less keyword options than `pandas.tools.pivot_table`. How about making `DataFrame.pivot` to call `pivot_table` internally to support same keywords as `pivot_table`?



Discussion:
I remember an issue about this, but can't find it now. What API change would this entail, e.g. visible to user?

From user, keywords only in pivot_table (`aggfunc`, `fill_value`, `margins` and `dropna`) will be available in `DataFrame.pivot`

oh...this is just a pass-trhu of keywords....ok then

Thanks, let me try.

I don't know if it is that simple: there is also a `pandas.pivot` function, which is what `DataFrame.pivot` calls, and this is clearly distinct from `pandas.pivot_table`. So I think the question is also: is there a reason there are two functions (pivot/pivot_table)? Have they incompatible functionality? Or could we maybe merge them into one? 

Because it would be strange to have a `pd.pivot` but a `DataFrame.pivot` calling `pd.pivot_table`. So I think we should think it a bit more through.

I've compared `pivot` and `pivot_table`, and understand that these are different function.
- `pivot` only intends pivotting, not aggregation. Thus it can handle non-numeric values, such as string.
- `pivot_table` intends pivotting with aggregation.

I noticed that `DataFrame.pivot_table` methods already exists separatelly, but not listed in api.rst (briefly explained in reshape.rst). So now I understand:
- Both functions should not be changed.
- Include `DataFrame.pivot_table` to api.rst.

If it is OK, I'll prepare.

More complete docs are certainly good! Maybe adding somewhere a better explanation of the difference between both functions could also be helpfull (in reshaping.rst or in the docstring of both (see also section)).

Hi (I'm new) but came into a problem with the 0.13.1 pivot_table function. 

Not totally sure if this is relevant to this discussion... but I lifted my question from http://stackoverflow.com/questions/23366016/pandas-0-13-1-pivot-table-pivot-error-not-in-0-12-0-should-and-how-i-go

So I have two lines of code below.

One that works successfully with Python 2.7.5 and Pandas 0.12.0

`dfp = pd.pivot_table(df, values=pivYears, rows=['partid'],cols=['finestflag_OV'], aggfunc=np.sum)`
And this one that does not work successfully with Python 2.7.6 and Pandas 0.13.1. I'm getting error refering to

`malloc: *** mach_vm_map …. error code = 3`
here's the code:

`dfp = pd.pivot_table(df, values=pivYears, index=['partid'],columns=['finestflag_OV'], aggfunc=np.sum)`
It could be that I am misunderstanding pivot vs. pivot_table and/or how it works in 0.13.1.

Lastly, since I've been using 0.12.0 for a while and am comfortable with it, is it possible to downgrade from 0.13.1 to 0.12.0 on my new machine? (Also, can I go back in Python versions so all my machines have the same version of Python and Pandas?)

Edits for questions: Both OS's are OS X 10.9.2.

Here's a subset of 9 rows of data in the CSV. https://github.com/nygeog/python/blob/master/pandas/pivot_sample.csv

The actual file has ~1.7 million rows. Which works fine on machine with 0.12.0.

Thanks, Danny


Resolving patch:
diff --git a/pandas/core/reshape.py b/pandas/core/reshape.py
--- a/pandas/core/reshape.py
+++ b/pandas/core/reshape.py
@@ -357,6 +357,11 @@ def pivot_simple(index, columns, values):
     Returns
     -------
     DataFrame
+
+    See also
+    --------
+    DataFrame.pivot_table : generalization of pivot that can handle
+        duplicate values for one index/column pair
     """
     if (len(index) != len(columns)) or (len(columns) != len(values)):
         raise AssertionError('Length of index, columns, and values must be the'
diff --git a/pandas/tools/pivot.py b/pandas/tools/pivot.py
--- a/pandas/tools/pivot.py
+++ b/pandas/tools/pivot.py
@@ -75,6 +75,11 @@ def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean',
     Returns
     -------
     table : DataFrame
+
+    See also
+    --------
+    DataFrame.pivot : pivot without aggregation that can handle
+        non-numeric data
     """
     index = _convert_by(index)
     columns = _convert_by(columns)


Test patch: