1

How can I set the maximum rows of pandas dataframe displayed in pycharm console? for example, I just want to see the first ten rows of a dataframe, but the pycharm console displayed most of the rows of this dataframe:

enter image description here

Is there has some command or setting method in pycharm?

Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138
yogazining
  • 119
  • 2
  • 10
  • I know I can use the head() method, but it is not very convenient because I have to use the head() method every time, so, how can I do? – yogazining Mar 22 '18 at 01:36

2 Answers2

4

To see just ten rows:

import pandas as pd
pd.set_option('display.max_rows',10)

This will fix your PD to show only first 10 rows always, no matter if you print dataframe to see more.

If you want to vary from time to time the use

df.head(10)
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
HimanshuGahlot
  • 561
  • 4
  • 11
0

Use indexing to return a portion of a pandas DataFrame

Some data:

date_time = ["2011-09-01", "2011-08-01", "2011-07-01", "2011-06-01", "2011-05-01"]
date_time = pd.to_datetime(date_time)
temp = [2, 4, 6, 4, 6]


DF = pd.DataFrame()
DF['temp'] = temp
DF = DF.set_index(date_time)

DF[:2] # rows to view

This returns the first two items of DF:

Out[22]: 
            temp
2011-09-01     2
2011-08-01     4
Dodge
  • 3,219
  • 3
  • 19
  • 38