priceData = pd.read_excel(r'...\Downloads\PriceData.xlsx', skiprows=range(1), usecols = 'B:SN', index_col = 0)
priceData = priceData.drop(priceData.index[[0,1]])
priceData.index.names = ['Date']
priceData.index = priceData.index.map(pd.to_datetime)
sortedPrices = priceData.sort_index(ascending=True)
# To adjust all time series data to start from 1990-01-25 to 2018-09-24
for column in sortedPrices.columns:
if np.isnan(sortedPrices[column].iloc[0]):
table = sortedPrices.drop([column],axis=1, inplace=True)
table
我打印了table
,并没有得到价格表(见下文,除了排序后,日期应该是从最早到最新),我收到了以下信息:
NoneType
请告诉我为什么:/
drop
将从sortedPrices
中删除这些项,但函数会在适当的位置执行此操作。返回值是None
,而不是表的副本。您需要输出sortedPrices
的新值,而不是单独的变量。你知道吗相关问题 更多 >
编程相关推荐