[PYTHON] [Pandas] What is set_option [How to use]

I wondered what the set_option of the Python pandas library was I didn't understand it immediately after checking it, so I will output it.

See pandas documentation

pandas.set_option(pat, value) Sets the value of the specified option.

It's literally like ** adding a specific option to a value **. Furthermore, the first argument takes a regular expression as follows.

Parameters: pat : str Regexp which should match a single option. Note: partial matches are supported for convenience, but unless you use the full option name (e.g. x.y.z.option_name), your code may break in future versions if new options with similar names are introduced. value : object New value of option.

There are many options you can do Please refer to the official document for details.

Here I would like to perform some usages.

Below is an example of using it with Jupyter notebook

** Do not display after the decimal point X digits ** Example: If you want to keep the output of the data frame below the decimal point 3

qiita.py


pd.set_option('display.precision',3)
#Set not to display 3 or less after the decimal point
# display.Was okay to omit

test = pd.DataFrame({'test':[5,7,9]})
#For the time being, 5,7,Prepare 9 data

print(test/3)
#Divide this data by 3

Output result (3 digits, the following is not displayed) image.png

** Change the number of displayed lines (do not hide automatically) ** In Jupyter etc., some lines are automatically hidden as shown below.

qiita.py


test = pd.DataFrame({'test':[10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10,
                             10,10,10,10,10,10,10,10,10,10]})

image.png

Therefore, I would like to display the specified number of lines. Here, I want to display 100 lines of data. Therefore, add the "max_rows" option. (Of course, there are also column options.)

qiita.py


pd.set_option("max_rows",100)

As a result, it was displayed image.png

that's all. I want to try various things when I want to display data.

Reference link

pandas documentation

Summary of frequently used grammar in pandas

I'm doing P.S blog and Twitter

From April 2020, we started Twitter and Blog with qiita. Please get along well

Recommended Posts

[Pandas] What is set_option [How to use]
How to use Pandas Rolling
[Python] How to use Pandas Series
[Python] Summary of how to use pandas
How to use is and == in Python
How to use pandas Timestamp and date_range
How to use xml.etree.ElementTree
How to use Python-shell
How to use tf.data
How to use virtualenv
How to use Seaboan
How to use image-match
How to use shogun
How to use Virtualenv
How to use numpy.vectorize
How to use pytest_report_header
How to use partial
How to use Bio.Phylo
How to use SymPy
How to use x-means
How to use WikiExtractor.py
How to use IPython
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use numpy
How to use TokyoTechFes2015
How to use venv
How to use dictionary {}
How to use Pyenv
How to use list []
How to use python-kabusapi
How to use OptParse
How to use return
How to use dotenv
How to use pyenv-virtualenv
How to use Go.mod
How to use imutils
How to use import
How to use Qt Designer
How to use search sorted
python3: How to use bottle (2)
Understand how to use django-filter
How to use the generator
[Python] How to use list 1
How to use FastAPI ③ OpenAPI
How to use Python argparse
Why Docker is so popular. What is Docker in the first place? How to use
How to use IPython Notebook
[Note] How to use virtualenv
How to use redis-py Dictionaries
Python: How to use pydub
[Python] How to use checkio
[Go] How to use "... (3 periods)"
I tried to summarize how to use pandas in python
How to use Django's GeoIp2
What is pip and how do you use it?
Scraping with Python-Selenium is old! ?? ・ ・ ・ How to use Pyppeteer
[Python] How to use input ()
How to use the decorator
[Introduction] How to use open3d