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