python内置函数map()
根据提供的函数对指定序列做映射
map(function,iterable,…)
- function----函数
- iterable-----一个或多个序列
def square(x):
return x**2
map(square,[1,2,3,4])
输出结果:[1,4,9,16]
time模块中的sleep()方法
time.sleep(t)
推迟调用线程的运行,t为秒数,表示进程挂起的时间
import time
print("Start:%s"%time.ctime())
time.sleep(5)
print("End:%s"%time.ctime())
time.ctime()将一个时间戳(按秒计算的浮点数)转换为time.asctime()形式,asctime()返回的是"Tue Dec 11 18:07:14 2008"(2008年12月11日 周二18时07分14秒)的24个字符的字符串,当time.ctime()无参数时相当于asctime(localtime(secs))
pandas.Grouper方法
为目标对象指定groupby
指令
pandas.Grouper ( key = None,level = None,freq = None,axis = 0,sort = False )
示例如下:
import pandas as pd
df = ...
df = df.groupby(pd.Grouper(key='day',freq='Y')).sum()