Pandas Merge Error iterable,而不是itertools.imap

时间:2018-05-17 17:42:43

标签: python-2.7 pandas

我正在尝试使用下面的pandas合并代码合并两个数据帧。每个数据框只有三列。我之前做过类似的合并没有问题。我在每个数据帧上都提供了.info()。我收到关于iterable而不是itertools.imap的错误。我不知道他们在谈论什么。任何提示非常感谢。

Data:

pio_smp2_sm.info()

<class 'pandas.core.frame.DataFrame'>
Int64Index: 12779 entries, 15 to 68311
Data columns (total 3 columns):
entityId          12779 non-null object
targetEntityId    12779 non-null object
eventTime         12779 non-null object
dtypes: object(3)
memory usage: 399.3+ KB


cm_smp2.info()

<class 'pandas.core.frame.DataFrame'>
Int64Index: 28035 entries, 40 to 698858
Data columns (total 3 columns):
user_id       28035 non-null object
product_id    28035 non-null object
time_stamp    28035 non-null object
dtypes: object(3)
memory usage: 876.1+ KB


Code:

comp_df2=pd.merge(pio_smp2_sm,cm_smp2,how='inner',left_on=['entityId','targetEntityId'],right_on=['user_id','product_id'])


Error:

TypeErrorTraceback (most recent call last)
<ipython-input-235-6882a22fe6a1> in <module>()
     23 
     24 
---> 25 comp_df2=pd.merge(pio_smp2_sm,cm_smp2,how='inner',left_on=['entityId','targetEntityId'],right_on=['user_id','product_id'])
     26 
     27 # print(comp_df2.shape[0])

/data2/user/anaconda2/lib/python2.7/site-packages/pandas/core/reshape/merge.pyc in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
     56                          copy=copy, indicator=indicator,
     57                          validate=validate)
---> 58     return op.get_result()
     59 
     60 

/data2/user/anaconda2/lib/python2.7/site-packages/pandas/core/reshape/merge.pyc in get_result(self)
    580                 self.left, self.right)
    581 
--> 582         join_index, left_indexer, right_indexer = self._get_join_info()
    583 
    584         ldata, rdata = self.left._data, self.right._data

/data2/user/anaconda2/lib/python2.7/site-packages/pandas/core/reshape/merge.pyc in _get_join_info(self)
    746         else:
    747             (left_indexer,
--> 748              right_indexer) = self._get_join_indexers()
    749 
    750             if self.right_index:

/data2/user/anaconda2/lib/python2.7/site-packages/pandas/core/reshape/merge.pyc in _get_join_indexers(self)
    725                                   self.right_join_keys,
    726                                   sort=self.sort,
--> 727                                   how=self.how)
    728 
    729     def _get_join_info(self):

/data2/user/anaconda2/lib/python2.7/site-packages/pandas/core/reshape/merge.pyc in _get_join_indexers(left_keys, right_keys, sort, how, **kwargs)
   1048 
   1049     # get left & right join labels and num. of levels at each location
-> 1050     llab, rlab, shape = map(list, zip(* map(fkeys, left_keys, right_keys)))
   1051 
   1052     # get flat i8 keys from label lists

TypeError: type object argument after * must be an iterable, not itertools.imap

0 个答案:

没有答案