为什么表出来的是非类型?

2024-09-24 02:23:59 发布

您现在位置:Python中文网/ 问答频道 /正文

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

请告诉我为什么:/

enter image description here


Tags: totruereadindexdownloadstablecolumnxlsx
1条回答
网友
1楼 · 发布于 2024-09-24 02:23:59

drop将从sortedPrices中删除这些项,但函数会在适当的位置执行此操作。返回值是None,而不是表的副本。您需要输出sortedPrices的新值,而不是单独的变量。你知道吗

相关问题 更多 >