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.
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)
** 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]})
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
that's all. I want to try various things when I want to display data.
Summary of frequently used grammar in pandas
From April 2020, we started Twitter and Blog with qiita. Please get along well
Recommended Posts