我想从一个大数据框中创建一个较小的dataFrames数组 下面的代码是一个包含有关会话日志的代码,我已将HH:MM格式的时间转换为Minutes,我希望转换为多个数据帧,其时间间隔为30分钟,例如 df [1] //包含从时间0到时间30的记录的示例数据帧 df [2] //从31到60,依此类推
import pandas as pd
a=[["0:01","1.2.3.4","A","NULL","IE5;Win2k"],
["0:09","1.2.3.enter code here4","B","A","IE5;Win2k"],
["0:10","2.3.4.5","C","NULL","IE4;Win98"],
["0:12","2.3.4.5","B","C","IE4;Win98"],
["0:15","2.3.4.5","E","C","IE4;Win98"],
["0:19","1.2.3.4","C","A","IE5;Win2k"],
["0:22","2.3.4.5","D","B","IE4;Win98"],
["0:22","1.2.3.4","A","NULL","IE4;Win98"],
["0:25","1.2.3.4","E","C","IE5;Win2k"],
["0:25","1.2.3.4","C","A","IE4;Win98"],
["0:33","1.2.3.4","B","C","IE4;Win98"],
["0:58","1.2.3.4","D","B","IE4;Win98"],
["1:10","1.2.3.4","E","D","IE4;Win98"],
["1:15","1.2.3.4","A","NULL","IE5;Win2k"],
["1:16","1.2.3.4","C","A","IE5;Win2k"],
["1:17","1.2.3.4","F","C","IE4;Win98"],
["1:25","1.2.3.4","F","C","IE5;Win2k"],
["1:30","1.2.3.4","B","A","IE5;Win2k"],
["1:36","1.2.3.4","D","B","IE5;Win2k"]]
df = pd.DataFrame(a,columns=['Time','IP','URL','Ref','Agent'])
df['Time'] = df['Time'].str.split(':').apply( lambda x: int(x[0])*60 + int(x[1]) )
df