0

I'm using the free version of canopy v1.4.1. I have similar problem stated in here: http://stackoverflow.com/questions/11361985/output-data-from-all-columns-in-a-dataframe-in-pandas but instead of getting the information about data frames I'm getting the actual table with the data listed in table:

enter image description here

where I want it to look like:

In [373]: names
Out[373]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 1690784 entries, 0 to 1690783
Data columns:
name   1690784  non-null values
sex    1690784  non-null values
births 1690784  non-null values
year   1690784  non-null values
dtypes: int64(2), object(2)

My code:

pandas as pd
pieces = [] # create the dictionary for the names

columns = ['name', 'sex', 'births']  # specify the columns names

for year in years: 
    path = 'yob%d.txt' % year
    frame = pd.read_csv(path, names = columns)

    frame['year'] = year
    pieces.append(frame)
    names = pd.concat(pieces, ignore_index = True)

print names
Jakubee
  • 634
  • 1
  • 9
  • 30

1 Answers1

0

It looks like a couple things are happening - 1) you are using iPython (because Canopy does), so pandas defaults to HTML pretty-printing when it can, and 2) you want the info on the whole dataframe.

To turn off the pretty-printing, do

import pandas as pd
pd.set_option('display.notebook_repr_html', False)

If you want to make it the default, you can add these lines in your iPython startup file (see here)

To get your dataframe info, you can just call

names.info()
Ajean
  • 5,528
  • 14
  • 46
  • 69