0

I am new to Pandas. My txt file does not have headers. Hence I am adding it explicitly. However after using df.columns, I am losing the top row of data, how can I avoid losing the top row/ first row ?

Code:

df1 = pd.read_csv('ABC.txt',sep = '\t')
headers =  ['name', 'age', 'group']
df1.columns = headers
df1.to_csv('newABC.txt', sep = '\t')

Input: Input

Output: output

Expected Output: expected output

anonymus
  • 39
  • 1
  • 6

0 Answers0