Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Issues with PyCharm and printing example of data

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()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading