ValueError Traceback (most recent call last) <ipython-input-2-feccf34e33ab> in <module> 9 10 # 根据交易卡号进行合并 ---> 11 merged_search_data = pd.merge(merged_data, search_data, on='交易卡号') 12 13 # 根据交易时间条件筛选数据 D:\anoconda3\lib\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, validate) 71 validate=None, 72 ) -> "DataFrame": ---> 73 op = _MergeOperation( 74 left, 75 right, D:\anoconda3\lib\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) 629 # validate the merge keys dtypes. We may need to coerce 630 # to avoid incompat dtypes --> 631 self._maybe_coerce_merge_keys() 632 633 # If argument passed to validate, D:\anoconda3\lib\site-packages\pandas\core\reshape\merge.py in _maybe_coerce_merge_keys(self) 1144 inferred_right in string_types and inferred_left not in string_types 1145 ): -> 1146 raise ValueError(msg) 1147 1148 # datetimelikes must match exactly ValueError: You are trying to merge on int64 and object columns. If you wish to proceed you should use pd.concat
时间: 2024-02-14 08:26:02 浏览: 180
python实现ICESat-2 ATL08转shapefile
这个错误是由于你尝试将一个 int64 列和一个 object 列进行合并造成的。如果你想继续进行合并操作,你应该使用 pd.concat() 函数。这个函数可以在两个数据框的行方向上进行连接。你可以尝试使用以下代码来替代原来的合并操作:
```
merged_search_data = pd.concat([merged_data, search_data], axis=1)
```
这样做将会将两个数据框按照列方向进行连接,而不是按照交易卡号进行合并。请确保两个数据框的列名和顺序是正确的。
阅读全文