Generating list on Python 3/Jupyter kills Kernel

864 Views Asked by At

I'm using a notebook on Python 3 to generate a list with a dataset of 200 observations. Every time I run it, the kernel disconnects with the error message: "The kernel for Desktop/Untitled2.ipynb appears to have died. It will restart automatically." The code I am using is:

early_congress = []
late_congress = []
import csv
import pandas as pd
import statistics
with open('bills.csv', 'r') as bill_file:
    fieldnames = ['bill_number', 'congress', 'bill_title', 'bill_subtitle']
    csv_reader = csv.DictReader(bill_file, delimiter = ',', skipinitialspace=True, 
                               fieldnames = fieldnames)
    for row in bill_file:
        if ['congress'] == '104th':
            early_congress.append('bill_subtitle', 'bill_number', 'congress')
            for row in early_congress:
                total_count = early_congress['bill_subtitle'].count
                print(total_count + 1)

I'm relatively new to Python so my understanding of how it operates is relatively new. I tried reinstalling Jupyter which didn't seem to change it. When this happens, what should I look for and is there a way to troubleshoot?

1

There are 1 best solutions below

0
On

When a kernel dies, it often means you have overloaded your notebook's alotted memory. this can be resolved by changing your jupyter notebook configuration to allow more RAM, or by breaking memory-intensive tasks into multiple blocks.