因此,当我尝试放置不同大小的数据帧时,总是会导致错误。你知道吗
import pandas as pd
from pandas import Series,DataFrame
import numpy as np
# For reading stock data from yahoo
import pandas_datareader as web
# For time stamps
from datetime import datetime
closing_df = web.DataReader(['AAPL','GOOG','MSFT','AMZN'],'yahoo',start,end)['Adj Close']
#when I do this, it is fine since the size are the same whereas
closing_df = web.DataReader(['AAPL','GOOG','MSFT','AMZN','BTC-USD'],'yahoo',start,end)['Adj Close']
#I always get this error
#ValueError: Index contains duplicate entries, cannot reshape
我试着有两个数据帧,一个用于科技公司,一个用于BTC-USD 但当我使用join、concat或merge时,似乎都不起作用 我想获取两个数据集的所有联合日期并将其放在一起,例如,如果两个数据帧都有2010-11-30,那么它将在数据帧中,但如果只有一个数据帧包含该日期,那么它将忽略或不将其放在联合数据帧中。 非常感谢
一种解决方法如下
然而,通过检查单个数据帧,看起来虽然tech只有财务日,但BTC也有周末和假日,因此它们检索到的是不同的日期。 使用上述连接将丢失BTC数据。 也许最好是外部连接,然后填充值:
相关问题 更多 >
编程相关推荐