2

I am trying to display 4 data frames in a list from a web-scraper project I'm working on. I'm new to Python/Pandas, and am trying to write a for loop to do this. My thinking is if I can set the display restrictions, it will just do this for each data frame in my list, if it means anything, I'm working out of a Jupyter Notebook. The only thing is, that I need to limit the number of columns, not rows, shown to only the first 5 (columns 0 - 4). I'm kind of at a loss here on how to do this.

I've tried to set up the initial loop as seen below, and I'm able to display each of my data-frames correctly, just not limited on columns like I want. I would also like to figure out how to add a header if you will, like a chart title in Excel to each, but that's a little less urgent at the moment.

Players = [MJ,KB,LJ,SC]
for players in Players:
    display(players)

Additional information is that each data-frame has 11 columns, each df is stored to the corresponding variable in the list above.

halfer
  • 19,824
  • 17
  • 99
  • 186
Dan Council
  • 37
  • 1
  • 6

1 Answers1

10

Check out this link: https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html

There is an option that you can set using:

import pandas as pd pd.set_option("display.max_columns", 4)

After doing so you can use display(players) and it should only show the first 4 columns

DZurico
  • 637
  • 4
  • 11