简体   繁体   English

无法执行pd.merge

[英]Unable to perform pd.merge

I have 2 csv's I want to perform outer join based on index (index is a combination of 2 columns) 我有2个csv,我想基于索引执行外部联接(索引是2列的组合)

frame1=pd.read_csv("Gamesa_G114 (Carlos Almeida)1.csv",index_col=['Dispositivo','Fecha'],sep=',',dtype='str')
frame2=pd.read_csv("Gamesa_G114 (Carlos Almeida).csv",index_col=['Dispositivo','Fecha'],sep=',',dtype='str')

Snapshot of both the frames 两个框架的快照 在此处输入图片说明

Now I am performing outer join 现在我正在执行外部联接

frame=pd.merge(left=frame1,right=frame2,left_index=True,right_index=True,how='outer',suffixes=('_left', '_right'))

But it gives an error 但它给出了一个错误

TypeError: unorderable types: str() > float() TypeError:不可排序的类型:str()> float()

For stacktrace of error http://pastebin.com/eWYfnMRT 有关错误的stacktrace http://pastebin.com/eWYfnMRT

Why it is saying TypeError: unorderable types: str() > float() if I have already specified dtype='str' while reading csv 为什么说TypeError:乱序类型:str()> float()如果我在读取csv时已经指定dtype ='str'

I have performed merge various times but never I have encountered this problem of type error. 我已经执行过多次合并,但是从未遇到过类型错误的问题。

Post edit Frame info 发布编辑框信息 在此处输入图片说明

This may be not a solution to your answer but a comment on dtype 这可能不是您答案的解决方案,而是对dtype的评论

You need to pass a dictionary in dtype Eg {'a': np.float64, 'b': np.int32} instead of the String. 您需要传递{'a': np.float64, 'b': np.int32} Eg {'a': np.float64, 'b': np.int32}而不是String的{'a': np.float64, 'b': np.int32}

I am using answer space to write this because i don't have enough permission to comment. 我使用答案空间来编写此内容,因为我没有足够的评论权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM