KeyError: "None of [['', '']] are in the [columns]" pandas python

Maybe you have white spaces around your column names, double check your csv file


By the print you posted, it seems like you have whitespaces as delimiters. pd.read_csv will read using , as default separator, so you have to explicitly state it:

pd.read_csv('source.txt',header=0, delim_whitespace=True)

simply write code to create a new CSV file and use a new file

 import numpy as np
 import pandas as pd
 import matplotlib.pyplot as plt
 pd.read_csv('source.txt',header=0, delim_whitespace=True)
 headers = ['ID','vocab','sumCI','sumnextCI','new_diff']
 df.columns = headers 
 df.to_csv('newsource.txt')