main.py 823 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @Author : liuyuqi
  5. @Contact : liuyuqi.gov@msn.cn
  6. @Time : 2020/02/23 20:21:23
  7. @Version : 1.0
  8. @License : Copyright © 2017-2020 liuyuqi. All Rights Reserved.
  9. @Desc :
  10. '''
  11. import pandas as pd
  12. import datetime
  13. def run():
  14. # df = pd.read_csv("disk_sample_smart_log_test_a.csv", nrows=4)
  15. df = pd.read_csv("disk_sample_smart_log_test_a.csv")
  16. print(df.iloc[[1]])
  17. res = df[["manufacturer", "model", "serial_number", "dt"]]
  18. res["dt"] = res['dt'].apply(
  19. lambda x: datetime.datetime.strptime(str(x), '%Y%m%d'))
  20. res["dt"] = res['dt'].apply(lambda x: x + datetime.timedelta(10))
  21. save(res)
  22. def save(df: pd.DataFrame):
  23. df.to_csv("result.csv", header=None, encoding="utf8", index=False)
  24. if __name__ == "__main__":
  25. run()