Reputation: 565
I have this line of code which reads a pandas file. Then, I want to define the columns names in the same line of code but it gives me an error. I am not sure how to solve...maybe a syntax? Please advise
Current State:
ratings = pd.read_csv('ratings.tsv',header=None,sep='\t', encoding= 'latin1')
Desired State:
rating = pd.read_csv('ratings.tsv', header=None,sep='\t', encoding= 'latin1',['id','age'])
Upvotes: 1
Views: 42
Reputation: 153550
Try, using the names
parameter in pd.read_csv:
rating = pd.read_csv('ratings.tsv',
header=None,
sep='\t',
encoding= 'latin1',
names = ['id', 'age'])
Upvotes: 3