Python处理时间
来源:互联网 发布:写算法 编辑:程序博客网 时间:2024/06/08 15:06
from dateutil.parser import parse
a = parse(‘2011-01-03’)
print(a)from dateutil.parser import parse
a = parse(‘Jan 31,1997 10:45 PM’)
print(a)from dateutil.parser import parse
a = parse(‘6/12/2011’,dayfirst = True)
print(a)
时间做索引,算数运算会按照日期运算自动对齐
from datetime import datetime
import pandas as pd
import numpy as np
dates = [datetime(2011,1,2),datetime(2011,1,5),datetime(2011,1,7),datetime(2011,1,8),datetime(2011,1,10),datetime(2011,1,12)]
ts = pd.Series(np.random.rand(6),index=dates)
print(ts)
a = ts + ts[::2]
print(a)from datetime import datetime
import pandas as pd
import numpy as np
longer_ts = pd.Series(np.random.rand(1000),index=pd.date_range(‘1/1/2000’,periods=1000))
print(longer_ts.truncate(after=’1/9/2001’))from datetime import datetime
import pandas as pd
import numpy as np
dates = [datetime(2011,1,2),datetime(2011,1,5),datetime(2011,1,7),datetime(2011,1,8),datetime(2011,1,10),datetime(2011,1,12)]
ts = pd.Series(np.random.rand(6),index=dates)
print(ts)
a = ts.resample(‘D’).sum()
print(a)a = pd.date_range(‘1/1/2000’,’1/3/2000 23:59’,freq=’4h’)
print(a)
- python datetime时间处理
- Python 时间处理
- python 时间处理
- python datetime处理时间
- python UNIX_TIMESTAMP时间处理
- python datetime处理时间
- python时间处理函数
- A005:python 时间处理
- python 时间戳处理
- python 时间戳处理
- python 时间处理
- python 时间处理
- python datetime处理时间
- python datetime处理时间
- python处理时间
- python-时间处理问题
- Python 时间处理
- python 时间处理
- 【笔试题】Week05
- 20171103-程序员的自我修养
- Ubuntu部署Django项目
- leetcode题解-44. Wildcard Matching
- bzoj4198 [Noi2015] [荷马史诗] Huffman 编码
- Python处理时间
- BZOJ2038: [2009国家集训队]小Z的袜子(hose)
- 第三届ACM/ICPC新生赛初赛题解
- 【Excel-2010】四种方式筛选重复数据
- 【BZOJ1580】【USACO2009Hol】杀手游戏 计算几何
- 数据链路层
- A
- Java自测题
- 7