save_result.py 827 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. '''
  4. @Auther :liuyuqi.gov@msn.cn
  5. @Time :2018/7/8 2:57
  6. @File :save_result.py
  7. '''
  8. import datetime.datetime
  9. import pandas as pd
  10. def save_result(df):
  11. '''
  12. 导出数据结果
  13. :param data:
  14. :return:
  15. '''
  16. # head = ["instance", "machine"]
  17. # data = [["ss", "aa"], ["ss", "aa"], ["ss", "aa"], ["ss", "aa"]]
  18. # df = pd.DataFrame(data, columns=head)
  19. df.to_csv(("../submit/submit_" + datetime.now().strftime('%Y%m%d_%H%M%S') + ".csv"), header=None,
  20. index=False)
  21. def marge_ab(df_a, df_b):
  22. '''
  23. 合并数据,并导出
  24. :param df_a:
  25. :param df_b:
  26. :return:
  27. '''
  28. path_ab = "submit_" + datetime.now().strftime('%Y%m%d_%H%M%S') + ".csv"
  29. df_ab = pd.merge(df_a, df_b)
  30. df_ab.to_csv(path_ab, header=None, index=False)