I tried to print the output from jupyter notebook cell to a csv file.

with open("output.csv","w")as output:
    group = df.groupby(['id','no_of_absents']).size().groupby(level=0).size()
    x=group.sort_values(ascending=False, kind='quicksort')
    output.write(str(x))

The dataset contains a total of 25000 id's. when tried to print the output to a file it is the same as in the output block. which has "..." in the middle.

40576     115
54678     114
95849     114
63191     113
         ...
161161      1
161174      1
161173      1
161172      1
161171      1

How to print the whole data instead of ... in the middle.

2 Answers

0
Thotsaphon Sirikutta On Best Solutions

just using pandas function .to_csv('filename.csv')

 x.to_csv('my_csv.csv')
0
Community On

You can change maximum print options with:

with pd.option_context('display.max_rows', None, 'display.max_columns', None):
    print(df)