<p>我认为您不应该使用merge来组合两个数据帧,以满足您所描述的特定需求。我最好建议使用<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html" rel="nofollow">concat</a>函数或<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.join.html" rel="nofollow">join</a>方法;例如,用法参考以下<a href="http://pandas.pydata.org/pandas-docs/stable/merging.html" rel="nofollow">docs</a>。你知道吗</p>
<p>为了解决你的问题,我写了一段代码。如果它是一个pandas系列对象,您应该能够通过指定一个新列将它添加到您的数据帧中。你知道吗</p>
<pre><code>import pandas as pd
# Making some definitions
ind = ["AAA", "BBB", "CCC"]
cols = ["val1","val2","val3"]
val1 = pd.Series(index=ind, data=[21,22,23])
val2 = pd.Series(index=ind, data=["qw","te","gb"])
val3 = pd.Series(index=ind, data=[1,2,3])
ser = [val1,val2,val3]
# Defining a dataframe using the defined series objects
df1 = pd.DataFrame(index=ind, data={cols[i]:ser[i] for i in range(3)})
df2 = pd.DataFrame(index=ind, data={cols[i]:ser[i] for i in range(2)})
# Making a dataframe from first two series objects and adding
# third column
df22 = df2.copy()
print("Test1, Before:")
print(df2)
df22["val3"] = val3
print("Test1, After:")
print(df22)
# Same thing done using join
dfj = df2.copy()
val3.name = "val3" #need name for join
dfj = dfj.join(val3)
print("Test2, After:")
print(dfj)
# same thing done using concat
dfc = df2.copy()
dfc = pd.concat([dfc,val3],axis=1)
print("Test3, After:")
print(dfc)
</code></pre>