datetime OSError:[Errno 22]无效的参数

时间:2018-12-18 09:59:44

标签: python pandas datetime eoserror

<ul>
            <item v-for='cat in categories' :category='cat'></item>

        </ul>

错误:import pandas as pd import datetime def open_csv(path): try: df = pd.read_csv(path) return df except FileNotFoundError: print("ERR: FileNotFoundError", path) data = open_csv("historical/BNBBTC") for d in data["Open_time"]: print(d) print(type(d)) print(datetime.datetime.fromtimestamp(d).strftime('%Y-%m-%d %H:%M:%S'))

我不明白是什么问题?如果b = int(“ 1514764800000”),那么一切正常!

2 个答案:

答案 0 :(得分:0)

import time并将datetime.datetime.fromtimestamp(d).strftime('%Y-%m-%d %H:%M:%S')替换为time.strftime('%Y-%m-%d %H:%M:%S')

答案 1 :(得分:0)

有点晚了,但您遇到的问题是时间戳以毫秒为单位,请像这样转换:

        milliSeconds = timestamp % 1000
        timestamp = timestamp / 1000
        converted = datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S') + f".{milliSeconds}"