首页 > 解决方案 > 名称“_Unspecified”未定义

问题描述

简单的 CSV 导入,但由于某种原因出现此错误,不明白为什么?

import pandas as pd
from sklearn.model_selection import train_test_split

data = pd.read_csv(r"C:\Users\train\Desktop\klopp.csv")

NameError:未定义名称“_Unspecified”

追溯..

runfile('C:/Users/train/Desktop/Spring 2020/Taylor/practice.py', wdir='C:/Users/train/Desktop/Spring 2020/Taylor') Traceback(最近一次通话最后):

文件“”,第 1 行,在运行文件中('C:/Users/train/Desktop/Spring 2020/Taylor/practice.py', wdir='C:/Users/train/Desktop/Spring 2020/Taylor')

文件“C:\Users\train\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py”,第 827 行,运行文件 execfile(文件名,命名空间)

文件“C:\Users\train\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py”,第 110 行,在 execfile exec(compile(f.read(), filename, 'exec'), namespace)

文件“C:/Users/train/Desktop/Spring 2020/Taylor/practice.py”,第 4 行,数据 = pd.read_csv(r"C:\Users\train\Desktop\klopp.csv")

文件“C:\Users\train\Anaconda3\lib\site-packages\pandas\io\parsers.py”,第 685 行,在 parser_f 返回 _read(filepath_or_buffer, kwds)

_read data = parser.read(nrows) 中的文件“C:\Users\train\Anaconda3\lib\site-packages\pandas\io\parsers.py”,第 463 行

文件“C:\Users\train\Anaconda3\lib\site-packages\pandas\io\parsers.py”,第 1169 行,读取 df = DataFrame(col_dict, columns=columns, index=index)

文件“C:\Users\train\Anaconda3\lib\site-packages\pandas\core\frame.py”,第 411 行,在init mgr = init_dict(data, index, columns, dtype=dtype)

文件“C:\Users\train\Anaconda3\lib\site-packages\pandas\core\internals\construction.py”,第 236 行,在 init_dict 中,如果缺少.any() 而不是 is_integer_dtype(dtype):

文件“C:\Users\train\Anaconda3\lib\site-packages\pandas\core\generic.py”,第 11723 行,在logical_func filter_type="bool",

文件“C:\Users\train\Anaconda3\lib\site-packages\pandas\core\series.py”,第 4086 行,在 _reduce 中使用 np.errstate(all="ignore"):

文件“C:\Users\train\Anaconda3\lib\site-packages\numpy\core\numeric.py”,第 3055 行,在init

NameError:未定义名称“_Unspecified”

标签: pandascsv

解决方案


推荐阅读