skip to Main Content

I have a Python script that produces a large amount of output in my VS Code terminal. However, some of the lines are shortened and displayed as "…" so I cannot see the complete output. I want to view the entire output of my script in the terminal.

I have tried looking for solutions in other similar questions but haven’t found a solution yet. Here is an example of my code and the truncated output:

import random
import numpy as np
import pandas as pd

class DescriptiveStatistics:
    def __init__(self, data):
        self.data = data
    
    def frequency_table(self):
        possible_values = sorted(set(self.data))
        counters = {x: 0 for x in possible_values}
        for x in counters:
            counters[x] = self.data.count(x)
        cumulative_relative_frequency = 0.0
        table_lines = []
        for k, v in counters.items():
            cumulative_relative_frequency += v/len(self.data)
            table_lines.append([k, v, v/len(self.data) ,cumulative_relative_frequency])
        return pd.DataFrame(
            table_lines,
            columns=[
                "Values",
                "Absolute Frequency",
                "Relative Frequemcy",
                "Cumulative Relative Frequency"
            ])

def main():
    print(f"===== Frequency Table =====")
    data = [random.randint(1,999) for _ in range(100)]
    descriptive_statistics = DescriptiveStatistics(data)
    print(descriptive_statistics.frequency_table())

if __name__ == "__main__":
    main()

Output:

===== Frequency Table =====
    Values  Absolute Frequency  Relative Frequemcy  Cumulative Relative Frequency
0        2                   1                0.01                           0.01
1       16                   1                0.01                           0.02
2       30                   1                0.01                           0.03
3       35                   1                0.01                           0.04
4       42                   1                0.01                           0.05
..     ...                 ...                 ...                            ...
93     954                   1                0.01                           0.96
94     955                   1                0.01                           0.97
95     959                   1                0.01                           0.98
96     983                   1                0.01                           0.99
97     995                   1                0.01                           1.00

2

Answers


  1. Try changing the settings of the terminal:

    Open the VS Code settings by pressing Ctrl + , (Windows/Linux) or Command + , (macOS). In the search bar, type "terminal.integrated.scrollback".

    Increase the value of "terminal.integrated.scrollback" to a larger number, like 9000 or something. This setting determines how many lines of output the terminal can store in its buffer.
    Save the settings and restart VS Code.

    Login or Signup to reply.
  2. Settings => (Search for "scrollback") => Then you can increase the number of lines for "Terminal › Integrated: Scrollback".

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search