我有一个Pandas系列,ts。
Date
2020-06-02 10.02
2020-06-03 10.45
2020-06-04 10.95
2020-06-05 11.23
为了绘图,我将索引转换为字符串,首先将其转换为数据框,然后应用lambda表达式,并将其作为Pandas系列提取出来。
dfn = ts.to_frame()
dfn.index = dfn.reset_index().apply(lambda x: x['Date'].strftime('%Y-%m-%d'), axis=1)
tsn = dfn.iloc[:, 0]
有更有效率的方法吗?