0

I am using Spyder as my python IDE.

I tried run this python code:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os

path = os.getcwd() + '\ex1data1.txt'
data = pd.read_csv(path, header = None, names = ['Population', 'Profit'])
data.head()

In theory it is supposed to show me a table of data since I am using

data.head()

at the end

but when I run it, it only shows :

enter image description here

I thought it was supposed to display a new window with the data table.

What is wrong?

1
  • Nothing, look at your variable explorer pan, you will find data (type: dataframe) click that and you can see your data. To print data head in console you have to type print(data.head()) Commented Aug 8, 2017 at 6:34

2 Answers 2

2

You are calling data.head() in .py script. The script is supposed to only read the data, not print it. Try print(data.head())

Sign up to request clarification or add additional context in comments.

Comments

1

You want to print your data.head() so do that... print(data.head())

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.