我的输入函数出错:
from nsepy import get_history
data1 = get_history(symbol='TATAMOTORS', start=date(2018,1,1),end=date(2018,6,7))
data2 = get_history(symbol='ALSEC', start=date(2018,1,1), end=date(2018,6,7))
data3=data1.join(data2)
print(data3)
这是我收到的ValueError
输出:
data3=data1.join(data2)
ValueError: columns overlap but no suffix specified:
Index(['Symbol', 'Series', 'Prev Close', 'Open', 'High', 'Low',
'Last','Close', 'VWAP', 'Volume','Turnover', 'Trades',
'Deliverable Volume','%Deliverble'],dtype='object')
有人可以建议我为什么会收到此错误吗?
答案 0 :(得分:0)
pd.DataFrame.join
用于按索引合并,如果它们没有重叠的列,则可以用于合并DataFrames
。您正在寻找的是merge
。
data3 = data1.merge(data2, how='outer')
注释
有几个警告,您没有导入pandas
,date
函数是从datetime.datetime
导入的,因此也应指定它。