使用pandas Series输出详细调试信息

0 投票
1 回答
2036 浏览
提问于 2025-04-18 03:29

我有一个包含76个元素的Pandas Series,当我试着打印这个Series(为了调试)时,输出结果中出现了“...”的缩略显示。有没有办法可以把Series的所有元素都完整地打印出来呢?

在这个例子中,这个Series叫做“data”。

print str(data) 

这段代码给我的结果是这样的:

Open               40.4568
High               40.4568
Low                 39.806
Close               40.114
Volume            796146.2
Active                   1
TP1_ema                700
stop_ema_width         0.5
LS_ema                  10
stop_window            210
target_width             3
LS_width                 0
TP1_pct                  1
TP1_width                4
stop_ema              1400
...
ValueSharesHeld       NaN
AccountIsWorth        NaN
Profit                NaN
BuyPrice              NaN
SellPrice             NaN
ShortPrice            NaN
BtcPrice              NaN
LongStopPrice         NaN
ShortStopPrice        NaN
LongTargetPrice       NaN
ShortTargetPrice      NaN
LTP1_Price            NaN
STP1_Price            NaN
TradeOpenPrice        NaN
TheEnd              False
Name: 2000-11-03 14:00, Length: 76, dtype: object

注意中间插入的“...”。我在Visual Studio 2013上使用PTVS(Python Tools for Visual Studio)进行调试时也遇到了同样的情况,使用Enthought Canopy时也是如此。

1 个回答

3
pd.options.display.max_rows = 100

默认设置是60(所以当打印数据框或系列时,如果元素超过60个,就会被截断)。

撰写回答