Python中的立即窗口设置 [英] Immediate Window settings in Python

查看:177
本文介绍了Python中的立即窗口设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2017进行Python开发。我经常使用立即窗口(和/或调试交互窗口---这个问题适用于两者)来检查运行代码时pandas DataFrames的值。显示
大型DataFrame(例如,具有大量列的数据框)的默认设置是显示几列,后跟省略号......后跟最后几列。您可以使用以下设置覆盖此项:

I'm using Visual Studio 2017 for Python development. I frequently use the Immediate Window (and/or the Debug Interactive Window --- this question applies to both) to check the value of pandas DataFrames while running code. The default setting for showing large DataFrames (e.g. one with a large number of columns) is to show a few columns, followed by an ellipses ... followed by the last few columns. You can override this by using the following setting:

pd.set_option(" display.max_columns",999)

pd.set_option("display.max_columns", 999)

设置最大数量显示的列(中间没有任何省略号)到999。

This sets the maximum number of columns displayed (without any ellipses in-between) to 999.

我的问题是,每次我点击Run运行我正在测试的程序时,它会重置显示的列数默认情况下,我每次运行程序时都必须重新输入上面的命令。这很乏味且耗时。有没有办法
更改默认值,所以每次运行程序时我都不必输入上面的内容?还有其他默认设置,例如显示没有省略号的最大行数,以及显示输出的列宽。我也想设置这些
的默认设置。

My problem is that every time I hit Run to run the program I'm testing, it resets the number of columns displayed to the default, and I have to re-enter the above command every time I run the program. This is tedious and time-consuming. Is there a way to change the default so I don't have to enter the above every time I run the program? There are other default settings as well, e.g. for the maximum number of rows displayed without an ellipses, and the column width of the display output. I'd like to set these default settings as well.

推荐答案

你好ED_White,

Hi ED_White,

欢迎来到MSDN论坛。

Welcome to MSDN forum.

根据您的描述,您可以在
profile_default / startup <中为python环境创建启动脚本/ strong> 目录。

According to your description, you can create startup scripts for the python environment in the profile_default/startup directory.

import pandas as pd
pd.set_option('display.max_rows', 999)
pd.set_option('precision', 5)

如果文件夹中有很多脚本,它们将按照其名称的顺序运行。 

If there are many scripts in folder, they will be run in order of their name. 

最好的问候,

Dylan


这篇关于Python中的立即窗口设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆