Mercury
Mercury

Reputation: 111

How to make a dataframe show in PyCharm?

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?

Upvotes: 9

Views: 45287

Answers (4)

Hossein Kourkchi
Hossein Kourkchi

Reputation: 11

Right click on the data frame, select Evaluate Expression, push the Evaluate button, select , and push "view as array".

Upvotes: 1

André
André

Reputation: 81

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.

Upvotes: 7

David
David

Reputation: 3026

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

Upvotes: 0

Yoshitha Penaganti
Yoshitha Penaganti

Reputation: 464

  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.

Upvotes: 4

Related Questions