Issues with PyCharm and printing example of data

Question:

So I’m trying to follow along to this basic tutorial. However, when I type df.head() PyCharm just says Process finished with exit code 0, and doesn’t actually print anything.

So first question is why does

df.head()

print nothing but

print(df.head()

work?

The tutorial doesn’t say anything about needing to use print().

Secondly, why does PyCharm keep breaking the table over multiple lines

enter image description here

There’s clearly abundant space to the right of Duration for Title. But PyCharm insists on breaking a table over multiple lines. How do I get it to actually present in 5 rows instead of 10?

Asked By: A Soutter

||

Answers:

You can change the following settings:

import pandas as pd
pd.options.display.max_columns = <how many columns do you want to show?>
pd.options.display.width = <max width of the dataframe when printing>

Showing any output without using a print statement only works with the interactive console. if you run the file, it wont work. You can find the "Python console" in Pycharm in the bottom of the screen.

To execute your code in the console, you can either write it there or select the code and click the shortcut you can find (and set) under:
preferences -> keymap -> search for "execute selection in python console"

Answered By: bitflip
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.