Home > Mobile >  Colab vs PyCharm - df.head() vs print(df.head())
Colab vs PyCharm - df.head() vs print(df.head())

Time:02-24

Why is df.head() (withoutprint) enough to print rows from the dataframe in Google Colab but in PyCharm, I have to actually use print(df.head()) as df.head() alone will not print any rows?

I am wondering if this could be due to different versions of Python between Google Colab and what I have in PyCharm on my local machine or if maybe it's due to a setting in PyCharm?

Not a big deal to have to use print in PyCharm but just asking since I am just learning Python and I was stuck for a while trying to figure out why df.head() wasn't working in PyCharm like it did in Google Colab until I figured I had to use print.

CodePudding user response:

Google Colab uses Jupyter notebook. If you are using a Jupyter notebook in Pycharm, it should work similarly to Google Colab. If you are using a normal Python File with .py extension, you have to use the print statement.

p.s. I use VS Code since it supports Jupyter notebooks directly in the editor and works similar to Google Colab.

  • Related