Traceback (most recent call last): File "D:\文档\pythonProject\main.py", line 56, in <module> merge_1=pd.merge([df1,df2,df3,df4,df5],on=['year','month','Stkcd']) TypeError: merge() missing 1 required positional argument: 'right'
时间: 2023-11-30 15:02:00 浏览: 163
TypeError: ‘required’ is an invalid argument for positionals 的解决方法
5星 · 资源好评率100%
这个错误提示是因为在使用 pd.merge() 函数时,缺少了要合并的右侧 DataFrame。
可以将代码修改为类似如下的形式:
```python
merge_1 = pd.merge(df1, df2, on=['year', 'month', 'Stkcd'])
merge_2 = pd.merge(merge_1, df3, on=['year', 'month', 'Stkcd'])
merge_3 = pd.merge(merge_2, df4, on=['year', 'month', 'Stkcd'])
merge_4 = pd.merge(merge_3, df5, on=['year', 'month', 'Stkcd'])
```
这样就可以按照顺序将五个 DataFrame 进行逐一合并,得到最终的结果。
阅读全文