Как удалить Traceback nameerror (последний вызов последний)Python

Программы на Python
Anonymous
Как удалить Traceback nameerror (последний вызов последний)

Сообщение Anonymous »

Я создаю серию, используя три словаря, в словаре нет ключевого слова или значений "name"/null, но отображается NameError: имя "null" не определено
перезапустите код в другом блокноте Jupyter

Код: Выделить всё

import pandas as pd
p1=pd.Series({'team':'england','keyplayer':'joe root','bowler':'jofra'})
p2=pd.Series({'team':'india','keyplayer':'virat kohli','bowler':'bumhra'})
p3=pd.Series({'team':'australia','keyplayer':'steve smith','bowler':'starc'})
df=pd.DataFrame([p1,p2,p3],index=['1','2','3'])

df.head()

Код: Выделить всё

NameError                                 Traceback (most recent call last)
~\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
700                 type_pprinters=self.type_printers,
701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
703             printer.flush()
704             return stream.getvalue()

~\Anaconda3\lib\site-packages\IPython\lib\pretty.py in pretty(self, obj)
400                         if cls is not object \
401                                 and callable(cls.__dict__.get('__repr__')):
--> 402                             return _repr_pprint(obj, self, cycle)
403
404             return _default_pprint(obj, self, cycle)

~\Anaconda3\lib\site-packages\IPython\lib\pretty.py in _repr_pprint(obj, p, cycle)
695     """A pprint that just redirects to the normal repr function."""
696     # Find newlines and replace them with p.break_()
--> 697     output = repr(obj)
698     for idx,output_line in enumerate(output.splitlines()):
699         if idx:

~\Anaconda3\lib\site-packages\pandas\core\base.py in __repr__(self)
80         Yields Bytestring in Py2, Unicode String in py3.
81         """
---> 82         return str(self)
83
84

~\Anaconda3\lib\site-packages\pandas\core\base.py in __str__(self)
59
60         if compat.PY3:
---> 61             return self.__unicode__()
62         return self.__bytes__()
63

~\Anaconda3\lib\site-packages\pandas\core\frame.py in __unicode__(self)
661             width = None
662         self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols,
--> 663                        line_width=width, show_dimensions=show_dimensions)
664
665         return buf.getvalue()

NameError: name 'null' is not defined
после отображения этой таблицы
она также показывает таблицу, но я не могу выполнить df.loc[:,['keyplayer','bowler']]
Я сталкиваюсь с той же ошибкой при импорте файла .csv

Подробнее здесь: https://stackoverflow.com/questions/564 ... -call-last

Вернуться в «Python»