0

I have 100 values in a dataframe and I want to print a nice table using tabulate. This works for me:

print(tabulate(dat], headers='keys', tablefmt='psql'))

Now, this prints out the entire dataframe. I couldn't get the relevant slicing info here: Understanding Python's slice notation

But I want to print out the first 5 values and then a few ... and then the last 5 values.

Example:

4
2
1
5
1
.
.
4
1
2
4
5

How can I do it?

cs95
  • 379,657
  • 97
  • 704
  • 746
ferengi
  • 437
  • 1
  • 4
  • 12

1 Answers1

1

You will need set_option, inyour case the max row should be 10, head 5 and tail 5

For example 

s=pd.Series([1,2,3,4,5,6,7,8,9,10,11,12])
pd.set_option('max_rows', 10)
s
Out[1443]: 
0      1
1      2
2      3
3      4
4      5
      ..
7      8
8      9
9     10
10    11
11    12
Length: 12, dtype: int64
BENY
  • 317,841
  • 20
  • 164
  • 234