I just got my hands on pandas and am figuring out how I can read a file. The file is from WRDS database and is the SP500 constituents list all the way back to 1960s. I check
What do you mean by display? Doesn't df['gvkey']
give you the data in the gvkey column?
If what you do is print the whole data frame to the console, then take a look at df.to_string()
, but it'll be hard to read if you have too many columns. Pandas won't print the whole thing by default if you have too many columns:
import pandas
import numpy
df1 = pandas.DataFrame(numpy.random.randn(10, 3), columns=['col%d' % d for d in range(3)] )
df2 = pandas.DataFrame(numpy.random.randn(10, 30), columns=['col%d' % d for d in range(30)] )
print df1 # <--- substitute by df2 to see the difference
print
print df1['col1']
print
print df1.to_string()