PSLmodels/microdf

Merging MicroDataFrames produces error

Opened this issue · 0 comments

Because of reset_index(inplace=True) being in the internals of pandas.merge, which microdf hasn't yet implemented:

In [2]: d1 = mdf.MicroDataFrame({"x": [1, 2], "y": [3, 4]}, weights=[7, 8])
                                                                                                                                                                                   
In [3]: d2 = mdf.MicroDataFrame({"x": [1, 2], "z": [5, 6]}, weights=[7, 8])
                                      
In [4]: d1.merge(d2, on="x")                                              
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-4-e8bd2011187f> in <module>
----> 1 d1.merge(d2, on="x")                                                                                                                                                       
              
~/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in merge(self, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
   7961             copy=copy,                                               
   7962             indicator=indicator,
-> 7963             validate=validate,                                  
   7964         )
   7965                        
~/anaconda3/lib/python3.7/site-packages/pandas/core/reshape/merge.py in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, val
idate)                                                      
     85         copy=copy,            
     86         indicator=indicator,        
---> 87         validate=validate,
     88     )                                                                                                        
     89     return op.get_result()                                  
                                               
~/anaconda3/lib/python3.7/site-packages/pandas/core/reshape/merge.py in __init__(self, left, right, how, on, left_on, right_on, axis, left_index, right_index, sort, suffixes, copy,
 indicator, validate)
    650             self.right_join_keys,                            
    651             self.join_names,
--> 652         ) = self._get_merge_keys()                                             
    653
    654         # validate the merge keys dtypes. We may need to coerce
                                                   
~/anaconda3/lib/python3.7/site-packages/pandas/core/reshape/merge.py in _get_merge_keys(self)                                                                                      
   1061                                                      
   1062         if right_drop:                                      
-> 1063             self.right = self.right._drop_labels_or_levels(right_drop)
   1064                      
   1065         return left_keys, right_keys, join_names
                                                                           
~/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in _drop_labels_or_levels(self, keys, axis)                                                                         
   1644             # Handle dropping columns labels                       
   1645             if labels_to_drop:
-> 1646                 dropped.drop(labels_to_drop, axis=1, inplace=True)
   1647         else:                                                      
   1648             # Handle dropping column levels                        
                                          
~/PSLmodels/microdf/microdf/generic.py in drop(self, labels, axis, index, columns, level, inplace, errors)                                                                         
    603     ):
    604         if inplace:                                                                                                                                                       
--> 605             raise NotImplementedError("inplace not yet implemented.")
    606         res = super().drop(     
    607             labels, axis, index, columns, level, inplace, errors
                 
NotImplementedError: inplace not yet implemented.

Note join doesn't error, but it also doesn't produce a MicroDataFrame:


In [5]: d1.set_index("x").join(d2.set_index("x"))
Out[5]: 
   y  z
x      
1  3  5
2  4  6

In [6]: d1.set_index("x").join(d2.set_index("x")).__class__
Out[6]: pandas.core.frame.DataFrame