KeyError: “None of [['', '']] are in the [columns]” pandas python
I would like to slice two columns in my data frame. This is my code for doing this: import pandas as pd df = pd.read_csv('source.txt',header=0) cidf=df.loc[:,['vocab','sumCI']] print(cidf) This is a sample of data: ID vocab sumCI sumnextCI new_diff 450 statu 3.0 0.0 3.0 391 provid 4.0 1.0 3.0 382 prescript 3.0 0.0 3.0 300 lymphoma 2.0 0.0 2.0 405 renew 2.0 0.0 2.0 **Firstly I got this error: ** KeyError: “None of [['', '']] are in the [columns]”' What I have tried: I tried putting a header with index 0 while reading the file, I tried to rename columns with this code: df.rename(columns=df.iloc