简体   繁体   中英

Generating list on Python 3/Jupyter kills Kernel

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM