Python 合并不起作用,即使我按索引设置它
union的合并很好,现在我需要合并union和GDP,所以我有3个集合的unionPython 合并不起作用,即使我按索引设置它,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 = 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等,因为它们可能以不同的编码运行(调用中的可用参数)。