Browse Source

修正了相关bug,初步测试中。。

liuyuqi-dellpc 5 years ago
parent
commit
16057f8c98
3 changed files with 12 additions and 4 deletions
  1. 1 0
      README.md
  2. 1 3
      code/sort_by_disk.py
  3. 10 1
      test/test_pandas.py

+ 1 - 0
README.md

@@ -4,6 +4,7 @@
 
 ```angular2html
 #远程执行:
+export PYTHONPATH=$PYTHONPATH:/root/ServerManager
 ssh://liuyuqi@localhost:2201/home/liuyuqi/anaconda3/envs/py36/bin/python -u /home/liuyuqi/workspace/ServerManager/code/data_preview.py -dAgg
 
 ```

+ 1 - 3
code/sort_by_disk.py

@@ -106,10 +106,8 @@ def deploy():
         deployInstance(row)
         # 整个instace都遍历了,第j主机无法再放入一个,所以添加j+1主机
         df3 = df3[df3["isdeploy"] == False]
-        # 重建行索引
-        # df3.reindex()
-        # df3.iloc[:, 0].reset_index(drop=True)
         row, column = df3.shape
+        df3 = df3.reset_index(drop=True)
         j = j + 1
         # j++之后表示新建主机,所以新主机没有部署任何实例,为false,然后初始化所有其他参数
         is_deploy = False

+ 10 - 1
test/test_pandas.py

@@ -96,7 +96,16 @@ def t8():
     print(df)
 
 
-t8()
+# DataFrame循环遍历
+def t9():
+    df = pd.DataFrame({'a': [1, 2, 3], 'b': [3, 4, 5]})
+    for row in df.itertuples():
+        # print("the index", row.Index)
+        print(row)
+    print("sum of row", row.a + row.b)
+
+
+t9()
 
 # result = pd.DataFrame(columns=list(["instanceid", "machineid"]), data=list())