最近有需要将分钟线的数据进行内联拼接,但时间没有必要精确到秒,微秒。
df['datetime'] = pd.to_datetime(df['datetime']) df = df.set_index('datetime') df.index = df.index.map(lambda x: x.replace(second=0, microsecond=0))
import datetime datetime.datetime.now().replace(second=0, microsecond=0)