在pandas中创建系列时出错

时间:2018-04-10 12:55:25

标签: python pandas

在pandas中创建一个系列时出现错误 每当我尝试打印我创建的系列时,都会出错。

我正在运行的代码:

import pandas as pd
data2 = [1,2,3,4]
index = ['a','b','c','d']
s = pd.Series(data2, index)
print(s.shape)
s

错误:

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    s
  File "C:\Python34\lib\idlelib\rpc.py", line 611, in displayhook
    text = repr(value)
  File "C:\Python34\lib\site-packages\pandas\core\base.py", line 80, in __repr__
    return str(self)
  File "C:\Python34\lib\site-packages\pandas\core\base.py", line 59, in __str__
    return self.__unicode__()
  File "C:\Python34\lib\site-packages\pandas\core\series.py", line 1060, in __unicode__
    width, height = get_terminal_size()
  File "C:\Python34\lib\site-packages\pandas\io\formats\terminal.py", line 33, in get_terminal_size
    return shutil.get_terminal_size()
  File "C:\Python34\lib\shutil.py", line 1071, in get_terminal_size
    size = os.get_terminal_size(sys.__stdout__.fileno())
AttributeError: 'NoneType' object has no attribute 'fileno'

1 个答案:

答案 0 :(得分:0)

您的错误与pyshell有关,而与大熊猫无关。 尝试直接通过pythonjupyter console运行它,因为您提供的代码是正确的。