Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display() in Python

Tags:

I'm trying to get my data head to display but I get an error message: NameError: name 'display' undefined

import pandas as pd data = pd.DataFrame(data=[tweet.text for tweet in tweets], columns=['Tweets'])  display(data.head(10)) 

Any ideas on how to fix this?

like image 284
Matt Wonderwall Avatar asked Mar 16 '18 19:03

Matt Wonderwall


People also ask

What is display function Python?

The disp. show command displays the form within the window that is running the Python script. (See this command used in the Basic Display example below.) The disp. popup command with waitforinput set to True displays the form as a popup window with the size and position you specify.

What is the difference between display and print in Python?

display is similar to write but prints strings and characters found within obj directly. Strings are printed without quotation marks or slashes, and characters are printed without #\ notation.

How do you display something in Python?

In python, the print statement is used to display text. In python with the print statement, you can use Single Quotes(') or Double Quotes(").

Which function is used to display results Python?

We can use print() function in Python to display some message or output on Python shell. Here EXPRESSION is the variable of any data type or string value that we want to display.


2 Answers

display is a function in the IPython.display module that runs the appropriate dunder method to get the appropriate data to ... display. If you really want to run it

from IPython.display import display import pandas as pd  data = pd.DataFrame(data=[tweet.text for tweet in tweets], columns=['Tweets'])  display(data.head(10)) 

But don't. IPython is already doing that for you. Just do:

data.head(10) 

You even might have IPython uninstalled, try:

pip install IPython 

or if running pip3:

pip3 install IPython 
like image 189
piRSquared Avatar answered Oct 04 '22 14:10

piRSquared


To solve the problem on pycaret, you have to open the below file -

..\env\Lib\site-packages\pycaret\datasets.py 

and add the line of code -

from IPython.display import display 
like image 44
guido albani Avatar answered Oct 04 '22 13:10

guido albani