Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 合并不起作用,即使我按索引设置它_Python_Pandas_Merge - Fatal编程技术网

Python 合并不起作用,即使我按索引设置它

Python 合并不起作用,即使我按索引设置它,python,pandas,merge,Python,Pandas,Merge,union的合并很好,现在我需要合并union和GDP,所以我有3个集合的union union = pd.merge(energy, ScimEn, how='outer', left_index=True, right_index=True) allunion = pd.merge(GDP, union, how='outer', left_index=True, right_index=True) allunion的合并返回: File "pandas/_libs/join_helper

union的合并很好,现在我需要合并union和GDP,所以我有3个集合的union

union = pd.merge(energy, ScimEn, how='outer', left_index=True, right_index=True)
allunion = pd.merge(GDP, union, how='outer', left_index=True, right_index=True)
allunion的合并返回:

File "pandas/_libs/join_helper.pxi", line 1063, in 
pandas._libs.join.outer_join_indexer_object
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 
18: ordinal not in range(128)

我怎样才能解决这个问题?即使我将它们直接组合到一个语句中,它也会执行相同的操作,我也会将所有数据帧的
set\u index
设置为相同,并合并以前的内部工作

有趣。你能打印三个数据帧吗?我想这是懒惰评估的结果。有关错误的一些详细信息,请参阅您使用的Python和Pandas的哪个版本?请包括示例数据。此外,您的数据似乎使用了特殊字符,是否使用了与英语不同的语言?请说明如何生成数据帧能量、GDP等,因为它们可能以不同的编码运行(调用中的可用参数)。