option_context() | Execute the code block with set options ( reset after execution ) |
import pandas as pd
my_data = pd.read_excel('D:\student.xlsx',index_col='id')
with pd.option_context('display.max_rows',6,'display.max_columns',3):
print(my_data)
print(pd.get_option("display.max_rows")) # 60
Output
name ... sex
id ...
1 John Deo ... female
2 Max Ruin ... male
3 Arnold ... male
.. ... ... ...
33 Kenn Rein ... female
34 Gain Toe ... male
35 Rows Noump ... female
[35 rows x 4 columns]
60
More on student excel file ( you can download and use ) having 35 rows of data
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.