jessica
jessica

Reputation: 1355

How to view data saved with a Pandas Dataframe

I have downloaded an Apple stock price timeseries dataset and loaded it into a pandas DataFrame. However, I don't see the object in Spyder's Variable Explorer. Where is it saved?

In any case, I would like to view the data.

import pandas as pd
import ystockquote as ys
aapl = ys.get_historical_prices("aapl", "2010-01-01", "2015-01-01")
data = pd.DataFrame(aapl)  

>>> data
<class 'pandas.core.frame.DataFrame'>
Index: 6 entries, Adj Close to Volume
Columns: 1258 entries, 2010-01-04 to 2014-12-31
dtypes: object(1258)

For some reason, the data doesn't display. Does the object not appearing in the Variable Explorer have anything to do with this issue?

Upvotes: 2

Views: 5105

Answers (4)

cloudscomputes
cloudscomputes

Reputation: 1474

If you want to see the data frame variable in variable explorer Uncheck "exclude unsupported data types" in the variable explorer's option

Upvotes: 1

Carlos Cordoba
Carlos Cordoba

Reputation: 34136

(Spyder dev here) Support for Pandas DataFrames was added in Spyder 2.3.1, so I suppose you are using a version older than that.

Spyder latest version is 2.3.8, so I encourage you to update to that version. It also fixes some problems with Series not showing in our Variable Explorer for Pandas 0.17.

Upvotes: 1

GIRISH RAMNANI
GIRISH RAMNANI

Reputation: 624

maybe this could work. Try adding a str method to the ur class and in that method show the data you want to show. eg

class Frame(DataFrame):

   def __str__(self):
       return self.as_matrix()

so this could show the matrix in the data explorer. this will only work if the data explorer uses the standard string representation of unknown types.

Upvotes: 0

saladi
saladi

Reputation: 3253

To print the first N rows, try:

data.head(N)

For more information, see here.

Upvotes: 1

Related Questions