# 起始对象都是时间戳
  #时间转化
  #datetime 必须将时间戳转化的datetime对象进行时区转化,不然在pd.to_json的时候转不过去,
  tzchina = timezone('Asia/Shanghai')
  df['d_date'] = df['d_date'].apply(lambda x: datetime.fromtimestamp(x).astimezone(tzchina))

  # pd时间序列,先将时间戳置为索引,才能进行时间转化
  tmp = df.set_index('d_date', drop=False)
  dt = pd.to_datetime(tmp.index, unit='s', utc=True).tz_convert('Asia/Shanghai').to_list()
  del df['d_date']
  df['d_date'] = dt

相关文章:

  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-01-19
猜你喜欢
  • 2021-11-26
  • 2021-05-20
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
相关资源
相似解决方案