pandas merge() 缺少 1 个必需的位置参数:“正确”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39574571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 02:02:25 来源:igfitidea点击:
merge() missing 1 required positional argument: 'right'
提问by mishakisha
I am doing a tutorial and I have a problem: My code:
我正在做一个教程,但我有一个问题: 我的代码:
import html5lib
import quandl
import pandas as pd
import pickle
pd.read_html("https://simple.wikipedia.org/wiki/List_of_U.S._states")
main_df = pd.DataFrame()
fiddy_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
for abbv in fiddy_states[0][0][1:]:
query = "FMAC/HPI_"+str(abbv)
df = quandl.get(query)
if main_df.empty:
main_df = df
else:
main_df = pd.merge (main_df , df, how = "right")
print(pd.merge(main_df))
and my error is:
我的错误是:
TypeError: merge() missing 1 required positional argument: 'right'
what's wrong?
怎么了?
回答by A.Kot
main_df.merge(df, how = "right")
回答by Vikika
right
basically means the dataframe on the right side. In your case you should remove df
from merge command and then choose right=df
. This will work.
right
基本上是指右侧的数据框。在您的情况下,您应该df
从合并命令中删除,然后选择right=df
. 这将起作用。