Zodiac Wang
  • Home
  • Categories
  • Tags
  • Archives

Python中几种日期时间对象之间的转换

PYTHON-基础-时间日期处理小结

datetime 中毫秒的格式化代码¶

In [1]:
import datetime
datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
Out[1]:
'2019-03-04 12:37:35.231597'

Pandas 中 timeindex 的毫秒¶

见 https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#dateoffset-objects

In [2]:
import pandas as pd
pd.date_range(datetime.datetime.now(), periods=5, freq='10L')
Out[2]:
DatetimeIndex(['2019-03-04 12:37:35.494893', '2019-03-04 12:37:35.504893',
               '2019-03-04 12:37:35.514893', '2019-03-04 12:37:35.524893',
               '2019-03-04 12:37:35.534893'],
              dtype='datetime64[ns]', freq='10L')

  • « 一个数据处理pipeline
  • Window平台下pygraphviz的安装 »

Published

3 4, 2019

Category

posts

Tags

  • python 16
  • time 1

Contact

  • Zodiac Wang - A Fantastic Learner
  • Powered by Pelican. Theme: Elegant