I'm working with CSV file with over million entries. I'm trying to read data for each candidate as a separate column. I was able to parse data for the first candidate but when I get to next candidate I'm getting error ['cand_nm'] not in index.
Here is the link to file: Link to data file
%matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
First candidate
reader_bachmann = pd.read_csv('P00000001-ALL.csv', squeeze=True, low_memory=False, nrows=411 )
print(reader_bachmann)
cand_bachmann = reader_bachmann[["cand_nm"]]
print(cand_bachmann)
Second candidate
reader_romney = pd.read_csv('P00000001-ALL.csv', skiprows=range(0,411) , na_filter =True, low_memory=False)
print(reader_romney)
cand_romney = reader_romney[["cand_nm"]]
print(cand_romney)
Error message
KeyError: "['cand_nm'] not in index"
skiprows=range(0,411)would have skipped the headers, causing 'cand_nm' to be undefined index