Andres Azqueta Andres Azqueta - 2 months ago 6
Python Question

Output not showing entirely in Python

The output when running a simple code breaks and is not entirely shown. What are the options to avoid the breaks?

22 December 23, 1989, Saturday, Late Edition - Final
23 December 22, 1989, Friday, Late Edition - Final
24 December 21, 1989, Thursday, Late Edition - Final
25 December 21, 1989, Thursday, Late Edition - Final
26 December 20, 1989, Wednesday, Late Edition - F...
27 December 20, 1989, Wednesday, Late Edition - F...
28 December 19, 1989, Tuesday, Late Edition - Final
29 December 18, 1989, Monday, Late Edition - Final
...
605 January 12, 2016 Tuesday
606 January 12, 2016 Tuesday 10:58 PM EST
607 January 12, 2016 Tuesday 8:28 PM EST
608 January 12, 2016 Tuesday 9:43 AM EST


Thanks!

PD: this is the code used to produce the file:

import json
import nltk
import re
import pandas

appended_data = []

for i in range(1989,2017):
df0 = pandas.DataFrame([json.loads(l) for l in open('NYT_%d.json' % i)])
df1 = pandas.DataFrame([json.loads(l) for l in open('USAT_%d.json' % i)])
df2 = pandas.DataFrame([json.loads(l) for l in open('WP_%d.json' % i)])
appended_data.append(df0)
appended_data.append(df1)
appended_data.append(df2)


appended_data = pandas.concat(appended_data)

print(appended_data.date)

tfv tfv
Answer

You need to change the display width or pandas. The option you are looking for is pd.set_option('display.width', 2000), but you may also find some other pandas options helpful which I use regularily:

pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', 2000)

Detailed description can be found here.