6

I have the following code in PyCharm.

import pandas as pd

df = pd.read_csv("test.csv")

print(df)
print(df.head())

But nothing shows up, and I get:

Process finished with exit code 0

How can I have data showing in PyCharm like in RStudio?

martineau
  • 119,623
  • 25
  • 170
  • 301
Mercury
  • 81
  • 1
  • 1
  • 4
  • 1
    Possible duplicate of [Pycharm Python console not printing the output](https://stackoverflow.com/questions/44544093/pycharm-python-console-not-printing-the-output) – vahdet Mar 07 '19 at 06:17
  • Can you please elaborate on how you run your code in PyCharm, i.e. in Run- or Debug-Mode or using the (python) console? – dorvak Mar 07 '19 at 08:21

4 Answers4

4
  1. First check the shape of df using df.shape() to get some insights and make sure that it is not empty.

  2. Use Debugger and place a debug point at print(df).

There is evaluator in debugger and you will be shown a view of df if you evaluate df.

Tamara Koliada
  • 1,200
  • 2
  • 14
  • 31
3

It's been a while this question was posted, but as I ended up here looking for an answer and found it elsewhere, I'll answer it. Maybe it can help someone else.

I solved it installing the package Tabulate: https://pypi.org/project/tabulate/

It's pretty straightforward to use. You import it:

from tabulate import tabulate

And then print your DataFrame:

print(tabulate(df, headers='keys'))

I saw it here.

rikyeah
  • 1,896
  • 4
  • 11
  • 21
André
  • 41
  • 5
1

When you read csv you need to check you have read successfully. Does the file located in the same folder? Does it not empty?

0

Concerning your second question:

You can use something called Jupyter notebook in PyCharm, but I would not recommend it, because it does not feel handy and looks very odd. Jupyter Notebook in the browser is much more appealing.

This is how Jupyter Notebook looks in PyCharm:

1

eshirvana
  • 23,227
  • 3
  • 22
  • 38
David
  • 2,926
  • 1
  • 27
  • 61