我是比较新的大熊猫,并试图定义dtypes读取大文件时,我收到以下错误:NameError: name 'int64' is not defined。
我确保安装并更新了 pandas 和 numpy,但据我所知,这是一个 python 错误。我经历了一些教程,没有人遇到过这个问题。请参阅下面的代码返回错误:
import pandas as pd
import numpy as np
data = pd.read_csv("file.csv", encoding="utf-16le", dtype={
"time": int64,
"created_date_sk": int64,
"eventType": object,
"itemId": int64,
"fieldId": int64,
"userId": int64
})
data.head()
Run Code Online (Sandbox Code Playgroud)
完整跟踪:
回溯(最近一次调用):文件“manipulate.py”,第 5 行,在模块“time”中:int64,NameError:未定义名称“int64”
我希望int64类型能够被识别,但它似乎只能读取 int 类型。对象类型似乎有效。