Python:使用tqdm跟踪作业进度

时间:2016-11-15 00:50:07

标签: python pandas progress

我使用以下代码来跟踪工作进度:

  0%|          | 0/5 [00:00<?, ?it/s]
 20%|██        | 1/5 [00:06<00:26,  6.62s/it]
215it [00:06,  4.63s/it]                     
1062it [00:06,  3.24s/it]
1976it [00:06,  2.27s/it]
2893it [00:07,  1.59s/it]
3811it [00:07,  1.11s/it]
4720it [00:07,  1.28it/s]
5650it [00:07,  1.83it/s]
6585it [00:07,  2.62it/s]
7520it [00:07,  3.74it/s]
8444it [00:07,  5.35it/s]
9378it [00:07,  7.64it/s]
10311it [00:07, 10.90it/s]
11218it [00:07, 15.57it/s]
12111it [00:08, 22.22it/s]
13004it [00:08, 31.70it/s]
13832it [00:08, 45.20it/s]
14618it [00:08, 64.36it/s]
15404it [00:08, 91.62it/s]
16149it [00:08, 129.91it/s]
16870it [00:08, 184.16it/s]
17560it [00:08, 259.28it/s]
18315it [00:08, 365.02it/s]
19162it [00:09, 512.00it/s]
19891it [00:09, 706.09it/s]
       :
       :

然后代码提供进度跟踪,如下所示:

let getUsers =
    use connection = openConnection()
    let getString = "select * from Accounts"
    use sqlCommand = new SqlCommand(getString, connection)
    try
        [
            use reader = sqlCommand.ExecuteReader()
            while reader.Read() do
                let floresID = reader.GetString 0
                let exName = reader.GetString 1
                let exPass = reader.GetString 2
                let user = [floresID=floresID; exName=exName; exPass=exPass]
                yield user
        ]
    with
        | :? SqlException as e -> failwithf "Došlo k chybě úrovni připojení:\n %s" e.Message
        | _ -> failwithf "Neznámá výjimka."

我想知道是否可以每5秒打印一次信息而不是每秒10次输出?非常感谢!

1 个答案:

答案 0 :(得分:1)

是的,只需使用mininterval参数:

tqdm.pandas(tqdm, mininterval=5)