将如标题中的时间提取出来是,书上给的代码是
df[‘recorded_at’] = df[‘recorded_at’].apply(lambda x: pd.to_datetime(str(int(x)), format=‘%Y’).strftime(‘%Y-%m-%d’))
结果运行不起来。经过haggle with gpt 3.5 一番之后,它终于能给出了正确的代码,如下
df[‘recorded_at’] = pd.to_datetime(df[‘recorded_at’]).dt.strftime(‘%Y-%m-%d’)
是以记之。