Repository: pandas-dev/pandas

Issue:
Memory Performance Regression in 0.13+
The following snippit runs fine in pandas 0.12 on a machine with 8GB of RAM but throws a `MemoryError` on a machine with 16GB of RAM when using pandas 0.13

``` python
date_index = pd.date_range('01-Jan-2012', '23-Jan-2013', freq='T')
daily_dates = date_index.to_period('D').to_timestamp('S','S')
fracofday = date_index.view(np.ndarray) - daily_dates.view(np.ndarray)
fracofday = fracofday.astype('timedelta64[ns]').astype(np.float64)/864e11
fracofday = pd.TimeSeries(fracofday, daily_dates)
index = pd.date_range(date_index.min().to_period('A').to_timestamp('D','S'),
                      date_index.max().to_period('A').to_timestamp('D','E'),
                      freq='D')
temp = pd.TimeSeries(1.0, index)
fracofday *= temp[fracofday.index]
```



Discussion:
this is a 'bug' that surfaced because of the join of the non-unique indexes even though they are equal is being done.....should be straightforward to fix (and that's why the memory is blowing up is a n^2 memory operation i think)

you can also do this in a frame, and would be better IMHO (e.g. guarantee to have a unique index if they values are the columns).

non-unique is very tricky and problematic...so avoid if possible


Resolving patch:
diff --git a/pandas/core/ops.py b/pandas/core/ops.py
--- a/pandas/core/ops.py
+++ b/pandas/core/ops.py
@@ -476,16 +476,15 @@ def wrapper(left, right, name=name):
             wrap_results = time_converted.wrap_results
 
         if isinstance(rvalues, pd.Series):
-            join_idx, lidx, ridx = left.index.join(rvalues.index, how='outer',
-                                                   return_indexers=True)
-            rindex = rvalues.index
+            rindex = getattr(rvalues,'index',rvalues)
             name = _maybe_match_name(left, rvalues)
             lvalues = getattr(lvalues, 'values', lvalues)
             rvalues = getattr(rvalues, 'values', rvalues)
             if left.index.equals(rindex):
                 index = left.index
             else:
-                index = join_idx
+                index, lidx, ridx = left.index.join(rindex, how='outer',
+                                                       return_indexers=True)
 
                 if lidx is not None:
                     lvalues = com.take_1d(lvalues, lidx)
diff --git a/vb_suite/join_merge.py b/vb_suite/join_merge.py
--- a/vb_suite/join_merge.py
+++ b/vb_suite/join_merge.py
@@ -202,3 +202,23 @@ def sample(values, k):
 """
 
 stmt = "ordered_merge(left, right, on='key', left_by='group')"
+
+#----------------------------------------------------------------------
+# outer join of non-unique
+# GH 6329
+
+setup = common_setup + """
+date_index = pd.date_range('01-Jan-2013', '23-Jan-2013', freq='T')
+daily_dates = date_index.to_period('D').to_timestamp('S','S')
+fracofday = date_index.view(np.ndarray) - daily_dates.view(np.ndarray)
+fracofday = fracofday.astype('timedelta64[ns]').astype(np.float64)/864e11
+fracofday = pd.TimeSeries(fracofday, daily_dates)
+index = pd.date_range(date_index.min().to_period('A').to_timestamp('D','S'),
+                      date_index.max().to_period('A').to_timestamp('D','E'),
+                      freq='D')
+temp = pd.TimeSeries(1.0, index)
+"""
+
+join_non_unique_equal = Benchmark('fracofday * temp[fracofday.index]', setup,
+                                   start_date=datetime(2013 1, 1))
+


Test patch: