NameError: 名称 'pd' 未定义 [英] NameError: name 'pd' is not defined

查看:82
本文介绍了NameError: 名称 'pd' 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Jupyter 中运行

I am attempting run in Jupyter

import pandas as pd                     
import matplotlib.pyplot as plt          # plotting
import numpy as np                       # dense matrices
from scipy.sparse import csr_matrix      # sparse matrices
%matplotlib inline

但是当加载数据集时

wiki = pd.read_csv('people_wiki.csv')
# add id column
wiki['id'] = range(0, len(wiki))
wiki.head(10)

以下错误仍然存​​在

NameError                                 Traceback (most recent call last)
<ipython-input-1-56330c326580> in <module>()
----> 1 wiki = pd.read_csv('people_wiki.csv')
      2 # add id column
      3 wiki['id'] = range(0, len(wiki))
      4 wiki.head(10)

NameError: name 'pd' is not defined

感谢任何建议

推荐答案

选择 Restart &清除输出并从头开始再次运行单元格.

Select Restart & Clear Output and run the cells again from the beginning.

我遇到了同样的问题,正如 Ivan 在评论中建议的那样,这解决了它.

I had the same issue, and as Ivan suggested in the comment, this resolved it.

这篇关于NameError: 名称 'pd' 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆